aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/resources/repos.py
blob: 85e24c73c78f7c7bbfb8cf7df14e9033d2d1eb74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from pygithub3.core.utils import OrderedDict

from .base import Resource
from .users import User
from .orgs import Org


class Repo(Resource):

    _dates = ('created_at', 'updated_at', 'pushed_at')
    _maps = {'owner': User, 'organization': Org, 'parent': 'self',
             'source': 'self'}

    def __str__(self):
        return '<Repo (%s)>' % getattr(self, 'name', '')


class Author(Resource):

    _dates = ('date')

    def __str__(self):
        return '<Author (%s)>' % getattr(self, 'name', '')


class Committer(Resource):

    _dates = ('date')

    def __str__(self):
        return '<Committer (%s)>' % getattr(self, 'name', '')


class Commit(Resource):

    _maps = {'author': Author, 'committer': Committer}
    #_maps.update({'tree': GitCommit})

    def __str__(self):
        return '<Commit (%s)>' % getattr(self, 'author', '')


class Stats(Resource):
    pass


class File(Resource):

    def __str__(self):
        return '<File (%s)>' % getattr(self, 'filename', '')


class GitCommit(Resource):

    _maps = {'author': User, 'committer': User, 'commit': Commit,
             'stats': Stats}
    _collection_maps = {'parents': 'self', 'files': File}

    def __str__(self):
        return '<GitCommit (%s)>' % getattr(self, 'sha', '')


class Comment(Resource):

    _dates = ('created_at', 'updated_at')
    _maps = {'user': User}

    def __str__(self):
        return '<Comment (%s)>' % getattr(self, 'user', '')


class Diff(Resource):

    _maps = {'base_commit': Commit}
    _collection_maps = {'commits': Commit, 'files': File}

    def __str__(self):
        return '<Diff (%s)>' % getattr(self, 'status', '')


class Tag(Resource):

    _maps = {'commit': GitCommit}

    def __str__(self):
        return '<Tag (%s)>' % getattr(self, 'name', '')


class Branch(Resource):

    _maps = {'commit': GitCommit}

    def __str__(self):
        return '<Branch (%s)>' % getattr(self, 'name', '')


class Download(Resource):

    def __str__(self):
        return '<Download (%s)>' % getattr(self, 'name', '')

    def ball_to_upload(self):
        return OrderedDict({
            'key': self.path, 'acl': self.acl, 'success_action_status': '201',
            'Filename': self.name, 'AWSAccessKeyId': self.accesskeyid,
            'Policy': self.policy, 'Signature': self.signature,
            'Content-Type': self.mime_type})


class Hook(Resource):

    _dates = ('created_at', 'pushed_at')

    def __str__(self):
        return '<Hook (%s)>' % getattr(self, 'name', '')