| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4d36f8f commit 00ce31a
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,17 +62,6 @@ def new_from_sha(cls, repo, sha1): | |||
| 62 | 62 | inst.size = oinfo.size | |
| 63 | 63 | return inst | |
| 64 | 64 | ||
| 65 | - def _set_self_from_args_(self, args_dict): | ||
| 66 | - """Initialize attributes on self from the given dict that was retrieved | ||
| 67 | - from locals() in the calling method. | ||
| 68 | - | ||
| 69 | - Will only set an attribute on self if the corresponding value in args_dict | ||
| 70 | - is not None""" | ||
| 71 | - for attr, val in args_dict.items(): | ||
| 72 | - if attr != "self" and val is not None: | ||
| 73 | - setattr( self, attr, val ) | ||
| 74 | - # END set all non-None attributes | ||
| 75 | - | ||
| 76 | 65 | def _set_cache_(self, attr): | |
| 77 | 66 | """Retrieve object information""" | |
| 78 | 67 | if attr == "size": | |
@@ -140,7 +129,10 @@ def __init__(self, repo, binsha, mode=None, path=None): | |||
| 140 | 129 | Path may not be set of the index object has been created directly as it cannot | |
| 141 | 130 | be retrieved without knowing the parent tree.""" | |
| 142 | 131 | super(IndexObject, self).__init__(repo, binsha) | |
| 143 | - self._set_self_from_args_(locals()) | ||
| 132 | + if mode is not None: | ||
| 133 | + self.mode = mode | ||
| 134 | + if path is not None: | ||
| 135 | + self.path = path | ||
| 144 | 136 | ||
| 145 | 137 | def __hash__(self): | |
| 146 | 138 | """:return: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,7 +108,26 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut | |||
| 108 | 108 | super(Commit,self).__init__(repo, binsha) | |
| 109 | 109 | if tree is not None: | |
| 110 | 110 | assert isinstance(tree, Tree), "Tree needs to be a Tree instance, was %s" % type(tree) | |
| 111 | - self._set_self_from_args_(locals()) | ||
| 111 | + if tree is not None: | ||
| 112 | + self.tree = tree | ||
| 113 | + if author is not None: | ||
| 114 | + self.author = author | ||
| 115 | + if authored_date is not None: | ||
| 116 | + self.authored_date = authored_date | ||
| 117 | + if author_tz_offset is not None: | ||
| 118 | + self.author_tz_offset = author_tz_offset | ||
| 119 | + if committer is not None: | ||
| 120 | + self.committer = committer | ||
| 121 | + if committed_date is not None: | ||
| 122 | + self.committed_date = committed_date | ||
| 123 | + if committer_tz_offset is not None: | ||
| 124 | + self.committer_tz_offset = committer_tz_offset | ||
| 125 | + if message is not None: | ||
| 126 | + self.message = message | ||
| 127 | + if parents is not None: | ||
| 128 | + self.parents = parents | ||
| 129 | + if encoding is not None: | ||
| 130 | + self.encoding = encoding | ||
| 112 | 131 | ||
| 113 | 132 | @classmethod | |
| 114 | 133 | def _get_intermediate_items(cls, commit): | |
@@ -434,7 +453,7 @@ def _deserialize(self, stream): | |||
| 434 | 453 | try: | |
| 435 | 454 | self.author.name = self.author.name.decode(self.encoding) | |
| 436 | 455 | except UnicodeDecodeError: | |
| 437 | - print >> sys.stderr, "Failed to decode author name: %s" % self.author.name | ||
| 456 | + print >> sys.stderr, "Failed to decode author name '%s' using encoding %s" % (self.author.name, self.encoding) | ||
| 438 | 457 | # END handle author's encoding | |
| 439 | 458 | ||
| 440 | 459 | # a stream from our data simply gives us the plain message | |
@@ -443,7 +462,7 @@ def _deserialize(self, stream): | |||
| 443 | 462 | try: | |
| 444 | 463 | self.message = self.message.decode(self.encoding) | |
| 445 | 464 | except UnicodeDecodeError: | |
| 446 | - print >> sys.stderr, "Failed to decode message: %s" % self.message | ||
| 465 | + print >> sys.stderr, "Failed to decode message '%s' using encoding %s" % (self.message, self.encoding) | ||
| 447 | 466 | # END exception handling | |
| 448 | 467 | return self | |
| 449 | 468 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments