| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -485,10 +485,10 @@ def readline(self, size=-1): | |||
| 485 | 485 | ||
| 486 | 486 | def readlines(self, size=-1): | |
| 487 | 487 | if self._nbr == self._size: | |
| 488 | - return list() | ||
| 488 | + return [] | ||
| 489 | 489 | ||
| 490 | 490 | # leave all additional logic to our readline method, we just check the size | |
| 491 | - out = list() | ||
| 491 | + out = [] | ||
| 492 | 492 | nbr = 0 | |
| 493 | 493 | while True: | |
| 494 | 494 | line = self.readline() | |
@@ -894,7 +894,7 @@ def transform_kwarg(self, name, value, split_single_char_options): | |||
| 894 | 894 | ||
| 895 | 895 | def transform_kwargs(self, split_single_char_options=True, **kwargs): | |
| 896 | 896 | """Transforms Python style kwargs into git command line options.""" | |
| 897 | - args = list() | ||
| 897 | + args = [] | ||
| 898 | 898 | kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0])) | |
| 899 | 899 | for k, v in kwargs.items(): | |
| 900 | 900 | if isinstance(v, (list, tuple)): | |
@@ -913,7 +913,7 @@ def __unpack_args(cls, arg_list): | |||
| 913 | 913 | return [arg_list.encode(defenc)] | |
| 914 | 914 | return [str(arg_list)] | |
| 915 | 915 | ||
| 916 | - outlist = list() | ||
| 916 | + outlist = [] | ||
| 917 | 917 | for arg in arg_list: | |
| 918 | 918 | if isinstance(arg_list, (list, tuple)): | |
| 919 | 919 | outlist.extend(cls.__unpack_args(arg)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,7 +61,7 @@ class Diffable(object): | |||
| 61 | 61 | :note: | |
| 62 | 62 | Subclasses require a repo member as it is the case for Object instances, for practical | |
| 63 | 63 | reasons we do not derive from Object.""" | |
| 64 | - __slots__ = tuple() | ||
| 64 | + __slots__ = () | ||
| 65 | 65 | ||
| 66 | 66 | # standin indicating you want to diff against the index | |
| 67 | 67 | class Index(object): | |
@@ -106,7 +106,7 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs): | |||
| 106 | 106 | :note: | |
| 107 | 107 | On a bare repository, 'other' needs to be provided as Index or as | |
| 108 | 108 | as Tree/Commit, or a git command error will occur""" | |
| 109 | - args = list() | ||
| 109 | + args = [] | ||
| 110 | 110 | args.append("--abbrev=40") # we need full shas | |
| 111 | 111 | args.append("--full-index") # get full index paths, not only filenames | |
| 112 | 112 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -121,7 +121,7 @@ def _set_cache_(self, attr): | |||
| 121 | 121 | ok = True | |
| 122 | 122 | except OSError: | |
| 123 | 123 | # in new repositories, there may be no index, which means we are empty | |
| 124 | - self.entries = dict() | ||
| 124 | + self.entries = {} | ||
| 125 | 125 | return | |
| 126 | 126 | finally: | |
| 127 | 127 | if not ok: | |
@@ -324,7 +324,7 @@ def from_tree(cls, repo, *treeish, **kwargs): | |||
| 324 | 324 | if len(treeish) == 0 or len(treeish) > 3: | |
| 325 | 325 | raise ValueError("Please specify between 1 and 3 treeish, got %i" % len(treeish)) | |
| 326 | 326 | ||
| 327 | - arg_list = list() | ||
| 327 | + arg_list = [] | ||
| 328 | 328 | # ignore that working tree and index possibly are out of date | |
| 329 | 329 | if len(treeish) > 1: | |
| 330 | 330 | # drop unmerged entries when reading our index and merging | |
@@ -471,9 +471,9 @@ def unmerged_blobs(self): | |||
| 471 | 471 | are at stage 3 will not have a stage 3 entry. | |
| 472 | 472 | """ | |
| 473 | 473 | is_unmerged_blob = lambda t: t[0] != 0 | |
| 474 | - path_map = dict() | ||
| 474 | + path_map = {} | ||
| 475 | 475 | for stage, blob in self.iter_blobs(is_unmerged_blob): | |
| 476 | - path_map.setdefault(blob.path, list()).append((stage, blob)) | ||
| 476 | + path_map.setdefault(blob.path, []).append((stage, blob)) | ||
| 477 | 477 | # END for each unmerged blob | |
| 478 | 478 | for l in mviter(path_map): | |
| 479 | 479 | l.sort() | |
@@ -576,8 +576,8 @@ def _to_relative_path(self, path): | |||
| 576 | 576 | ||
| 577 | 577 | def _preprocess_add_items(self, items): | |
| 578 | 578 | """ Split the items into two lists of path strings and BaseEntries. """ | |
| 579 | - paths = list() | ||
| 580 | - entries = list() | ||
| 579 | + paths = [] | ||
| 580 | + entries = [] | ||
| 581 | 581 | ||
| 582 | 582 | for item in items: | |
| 583 | 583 | if isinstance(item, string_types): | |
@@ -610,7 +610,7 @@ def _store_path(self, filepath, fprogress): | |||
| 610 | 610 | @unbare_repo | |
| 611 | 611 | @git_working_dir | |
| 612 | 612 | def _entries_for_paths(self, paths, path_rewriter, fprogress, entries): | |
| 613 | - entries_added = list() | ||
| 613 | + entries_added = [] | ||
| 614 | 614 | if path_rewriter: | |
| 615 | 615 | for path in paths: | |
| 616 | 616 | if osp.isabs(path): | |
@@ -742,7 +742,7 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non | |||
| 742 | 742 | # automatically | |
| 743 | 743 | # paths can be git-added, for everything else we use git-update-index | |
| 744 | 744 | paths, entries = self._preprocess_add_items(items) | |
| 745 | - entries_added = list() | ||
| 745 | + entries_added = [] | ||
| 746 | 746 | # This code needs a working tree, therefore we try not to run it unless required. | |
| 747 | 747 | # That way, we are OK on a bare repository as well. | |
| 748 | 748 | # If there are no paths, the rewriter has nothing to do either | |
@@ -809,7 +809,7 @@ def handle_null_entries(self): | |||
| 809 | 809 | def _items_to_rela_paths(self, items): | |
| 810 | 810 | """Returns a list of repo-relative paths from the given items which | |
| 811 | 811 | may be absolute or relative paths, entries or blobs""" | |
| 812 | - paths = list() | ||
| 812 | + paths = [] | ||
| 813 | 813 | for item in items: | |
| 814 | 814 | if isinstance(item, (BaseIndexEntry, (Blob, Submodule))): | |
| 815 | 815 | paths.append(self._to_relative_path(item.path)) | |
@@ -858,7 +858,7 @@ def remove(self, items, working_tree=False, **kwargs): | |||
| 858 | 858 | been removed effectively. | |
| 859 | 859 | This is interesting to know in case you have provided a directory or | |
| 860 | 860 | globs. Paths are relative to the repository. """ | |
| 861 | - args = list() | ||
| 861 | + args = [] | ||
| 862 | 862 | if not working_tree: | |
| 863 | 863 | args.append("--cached") | |
| 864 | 864 | args.append("--") | |
@@ -897,7 +897,7 @@ def move(self, items, skip_errors=False, **kwargs): | |||
| 897 | 897 | ||
| 898 | 898 | :raise ValueError: If only one item was given | |
| 899 | 899 | GitCommandError: If git could not handle your request""" | |
| 900 | - args = list() | ||
| 900 | + args = [] | ||
| 901 | 901 | if skip_errors: | |
| 902 | 902 | args.append('-k') | |
| 903 | 903 | ||
@@ -910,7 +910,7 @@ def move(self, items, skip_errors=False, **kwargs): | |||
| 910 | 910 | ||
| 911 | 911 | # first execute rename in dryrun so the command tells us what it actually does | |
| 912 | 912 | # ( for later output ) | |
| 913 | - out = list() | ||
| 913 | + out = [] | ||
| 914 | 914 | mvlines = self.repo.git.mv(args, paths, **kwargs).splitlines() | |
| 915 | 915 | ||
| 916 | 916 | # parse result - first 0:n/2 lines are 'checking ', the remaining ones | |
@@ -1041,9 +1041,9 @@ def handle_stderr(proc, iter_checked_out_files): | |||
| 1041 | 1041 | # line contents: | |
| 1042 | 1042 | stderr = stderr.decode(defenc) | |
| 1043 | 1043 | # git-checkout-index: this already exists | |
| 1044 | - failed_files = list() | ||
| 1045 | - failed_reasons = list() | ||
| 1046 | - unknown_lines = list() | ||
| 1044 | + failed_files = [] | ||
| 1045 | + failed_reasons = [] | ||
| 1046 | + unknown_lines = [] | ||
| 1047 | 1047 | endings = (' already exists', ' is not in the cache', ' does not exist at stage', ' is unmerged') | |
| 1048 | 1048 | for line in stderr.splitlines(): | |
| 1049 | 1049 | if not line.startswith("git checkout-index: ") and not line.startswith("git-checkout-index: "): | |
@@ -1106,7 +1106,7 @@ def handle_stderr(proc, iter_checked_out_files): | |||
| 1106 | 1106 | proc = self.repo.git.checkout_index(args, **kwargs) | |
| 1107 | 1107 | # FIXME: Reading from GIL! | |
| 1108 | 1108 | make_exc = lambda: GitCommandError(("git-checkout-index",) + tuple(args), 128, proc.stderr.read()) | |
| 1109 | - checked_out_files = list() | ||
| 1109 | + checked_out_files = [] | ||
| 1110 | 1110 | ||
| 1111 | 1111 | for path in paths: | |
| 1112 | 1112 | co_path = to_native_path_linux(self._to_relative_path(path)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -187,7 +187,7 @@ def read_cache(stream): | |||
| 187 | 187 | * content_sha is a 20 byte sha on all cache file contents""" | |
| 188 | 188 | version, num_entries = read_header(stream) | |
| 189 | 189 | count = 0 | |
| 190 | - entries = dict() | ||
| 190 | + entries = {} | ||
| 191 | 191 | ||
| 192 | 192 | read = stream.read | |
| 193 | 193 | tell = stream.tell | |
@@ -236,7 +236,7 @@ def write_tree_from_cache(entries, odb, sl, si=0): | |||
| 236 | 236 | :param sl: slice indicating the range we should process on the entries list | |
| 237 | 237 | :return: tuple(binsha, list(tree_entry, ...)) a tuple of a sha and a list of | |
| 238 | 238 | tree entries being a tuple of hexsha, mode, name""" | |
| 239 | - tree_items = list() | ||
| 239 | + tree_items = [] | ||
| 240 | 240 | tree_items_append = tree_items.append | |
| 241 | 241 | ci = sl.start | |
| 242 | 242 | end = sl.stop | |
@@ -295,7 +295,7 @@ def aggressive_tree_merge(odb, tree_shas): | |||
| 295 | 295 | :param tree_shas: 1, 2 or 3 trees as identified by their binary 20 byte shas | |
| 296 | 296 | If 1 or two, the entries will effectively correspond to the last given tree | |
| 297 | 297 | If 3 are given, a 3 way merge is performed""" | |
| 298 | - out = list() | ||
| 298 | + out = [] | ||
| 299 | 299 | out_append = out.append | |
| 300 | 300 | ||
| 301 | 301 | # one and two way is the same for us, as we don't have to handle an existing | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ class Blob(base.IndexObject): | |||
| 20 | 20 | file_mode = 0o100644 | |
| 21 | 21 | link_mode = 0o120000 | |
| 22 | 22 | ||
| 23 | - __slots__ = tuple() | ||
| 23 | + __slots__ = () | ||
| 24 | 24 | ||
| 25 | 25 | @property | |
| 26 | 26 | def mime_type(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -316,7 +316,7 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, | |||
| 316 | 316 | parent_commits = [repo.head.commit] | |
| 317 | 317 | except ValueError: | |
| 318 | 318 | # empty repositories have no head commit | |
| 319 | - parent_commits = list() | ||
| 319 | + parent_commits = [] | ||
| 320 | 320 | # END handle parent commits | |
| 321 | 321 | else: | |
| 322 | 322 | for p in parent_commits: | |
@@ -450,7 +450,7 @@ def _deserialize(self, stream): | |||
| 450 | 450 | readline = stream.readline | |
| 451 | 451 | self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id << 12, '') | |
| 452 | 452 | ||
| 453 | - self.parents = list() | ||
| 453 | + self.parents = [] | ||
| 454 | 454 | next_line = None | |
| 455 | 455 | while True: | |
| 456 | 456 | parent_line = readline() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,7 @@ def tree_entries_from_data(data): | |||
| 50 | 50 | space_ord = ord(' ') | |
| 51 | 51 | len_data = len(data) | |
| 52 | 52 | i = 0 | |
| 53 | - out = list() | ||
| 53 | + out = [] | ||
| 54 | 54 | while i < len_data: | |
| 55 | 55 | mode = 0 | |
| 56 | 56 | ||
@@ -132,18 +132,18 @@ def traverse_trees_recursive(odb, tree_shas, path_prefix): | |||
| 132 | 132 | :param path_prefix: a prefix to be added to the returned paths on this level, | |
| 133 | 133 | set it '' for the first iteration | |
| 134 | 134 | :note: The ordering of the returned items will be partially lost""" | |
| 135 | - trees_data = list() | ||
| 135 | + trees_data = [] | ||
| 136 | 136 | nt = len(tree_shas) | |
| 137 | 137 | for tree_sha in tree_shas: | |
| 138 | 138 | if tree_sha is None: | |
| 139 | - data = list() | ||
| 139 | + data = [] | ||
| 140 | 140 | else: | |
| 141 | 141 | data = tree_entries_from_data(odb.stream(tree_sha).read()) | |
| 142 | 142 | # END handle muted trees | |
| 143 | 143 | trees_data.append(data) | |
| 144 | 144 | # END for each sha to get data for | |
| 145 | 145 | ||
| 146 | - out = list() | ||
| 146 | + out = [] | ||
| 147 | 147 | out_append = out.append | |
| 148 | 148 | ||
| 149 | 149 | # find all matching entries and recursively process them together if the match | |
@@ -193,7 +193,7 @@ def traverse_tree_recursive(odb, tree_sha, path_prefix): | |||
| 193 | 193 | * [1] mode as int | |
| 194 | 194 | * [2] path relative to the repository | |
| 195 | 195 | :param path_prefix: prefix to prepend to the front of all returned paths""" | |
| 196 | - entries = list() | ||
| 196 | + entries = [] | ||
| 197 | 197 | data = tree_entries_from_data(odb.stream(tree_sha).read()) | |
| 198 | 198 | ||
| 199 | 199 | # unpacking/packing is faster than accessing individual items | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,7 +60,7 @@ class UpdateProgress(RemoteProgress): | |||
| 60 | 60 | CLONE, FETCH, UPDWKTREE = [1 << x for x in range(RemoteProgress._num_op_codes, RemoteProgress._num_op_codes + 3)] | |
| 61 | 61 | _num_op_codes = RemoteProgress._num_op_codes + 3 | |
| 62 | 62 | ||
| 63 | - __slots__ = tuple() | ||
| 63 | + __slots__ = () | ||
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | 66 | BEGIN = UpdateProgress.BEGIN | |
@@ -139,7 +139,7 @@ def _get_intermediate_items(self, item): | |||
| 139 | 139 | try: | |
| 140 | 140 | return type(self).list_items(item.module()) | |
| 141 | 141 | except InvalidGitRepositoryError: | |
| 142 | - return list() | ||
| 142 | + return [] | ||
| 143 | 143 | # END handle intermediate items | |
| 144 | 144 | ||
| 145 | 145 | @classmethod | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ class RootUpdateProgress(UpdateProgress): | |||
| 22 | 22 | 1 << x for x in range(UpdateProgress._num_op_codes, UpdateProgress._num_op_codes + 4)] | |
| 23 | 23 | _num_op_codes = UpdateProgress._num_op_codes + 4 | |
| 24 | 24 | ||
| 25 | - __slots__ = tuple() | ||
| 25 | + __slots__ = () | ||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | 28 | BEGIN = RootUpdateProgress.BEGIN | |
@@ -38,7 +38,7 @@ class RootModule(Submodule): | |||
| 38 | 38 | """A (virtual) Root of all submodules in the given repository. It can be used | |
| 39 | 39 | to more easily traverse all submodules of the master repository""" | |
| 40 | 40 | ||
| 41 | - __slots__ = tuple() | ||
| 41 | + __slots__ = () | ||
| 42 | 42 | ||
| 43 | 43 | k_root_name = '__ROOT__' | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,7 +189,7 @@ def __init__(self, repo, binsha, mode=tree_id << 12, path=None): | |||
| 189 | 189 | def _get_intermediate_items(cls, index_object): | |
| 190 | 190 | if index_object.type == "tree": | |
| 191 | 191 | return tuple(index_object._iter_convert_to_object(index_object._cache)) | |
| 192 | - return tuple() | ||
| 192 | + return () | ||
| 193 | 193 | ||
| 194 | 194 | def _set_cache_(self, attr): | |
| 195 | 195 | if attr == "_cache": | |
| Back | FazBrowse Home | New Git URL |
0 commit comments