| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3face90 commit 1fa1ce2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -569,25 +569,23 @@ def _preprocess_add_items(self, items): | |||
| 569 | 569 | """ Split the items into two lists of path strings and BaseEntries. """ | |
| 570 | 570 | paths = [] | |
| 571 | 571 | entries = [] | |
| 572 | - | ||
| 573 | - if isinstance(items, string_types): | ||
| 574 | - paths.append(self._to_relative_path(items)) | ||
| 575 | - elif isinstance(items, (Blob, Submodule)): | ||
| 576 | - entries.append(BaseIndexEntry.from_blob(items)) | ||
| 577 | - elif isinstance(items, BaseIndexEntry): | ||
| 578 | - entries.append(items) | ||
| 579 | - else: | ||
| 580 | - for item in items: | ||
| 581 | - if isinstance(item, string_types): | ||
| 582 | - paths.append(self._to_relative_path(item)) | ||
| 583 | - elif isinstance(item, (Blob, Submodule)): | ||
| 584 | - entries.append(BaseIndexEntry.from_blob(item)) | ||
| 585 | - elif isinstance(item, BaseIndexEntry): | ||
| 586 | - entries.append(item) | ||
| 587 | - else: | ||
| 588 | - raise TypeError("Invalid Type: %r" % item) | ||
| 572 | + # check if is iterable, else put in list | ||
| 573 | + try: | ||
| 574 | + test_item = iter(items) | ||
| 575 | + except TypeError: | ||
| 576 | + items = [items] | ||
| 577 | + | ||
| 578 | + for item in items: | ||
| 579 | + if isinstance(item, string_types): | ||
| 580 | + paths.append(self._to_relative_path(item)) | ||
| 581 | + elif isinstance(item, (Blob, Submodule)): | ||
| 582 | + entries.append(BaseIndexEntry.from_blob(item)) | ||
| 583 | + elif isinstance(item, BaseIndexEntry): | ||
| 584 | + entries.append(item) | ||
| 585 | + else: | ||
| 586 | + raise TypeError("Invalid Type: %r" % item) | ||
| 589 | 587 | # END for each item | |
| 590 | - return (paths, entries) | ||
| 588 | + return paths, entries | ||
| 591 | 589 | ||
| 592 | 590 | def _store_path(self, filepath, fprogress): | |
| 593 | 591 | """Store file at filepath in the database and return the base index entry | |
@@ -808,18 +806,19 @@ def _items_to_rela_paths(self, items): | |||
| 808 | 806 | """Returns a list of repo-relative paths from the given items which | |
| 809 | 807 | may be absolute or relative paths, entries or blobs""" | |
| 810 | 808 | paths = [] | |
| 811 | - if isinstance(items, (BaseIndexEntry, (Blob, Submodule))): | ||
| 812 | - paths.append(self._to_relative_path(items.path)) | ||
| 813 | - elif isinstance(items, string_types): | ||
| 814 | - paths.append(self._to_relative_path(items)) | ||
| 815 | - else: | ||
| 816 | - for item in items: | ||
| 817 | - if isinstance(item, (BaseIndexEntry, (Blob, Submodule))): | ||
| 818 | - paths.append(self._to_relative_path(item.path)) | ||
| 819 | - elif isinstance(item, string_types): | ||
| 820 | - paths.append(self._to_relative_path(item)) | ||
| 821 | - else: | ||
| 822 | - raise TypeError("Invalid item type: %r" % item) | ||
| 809 | + # check if is iterable, else put in list | ||
| 810 | + try: | ||
| 811 | + test_item = iter(items) | ||
| 812 | + except TypeError: | ||
| 813 | + items = [items] | ||
| 814 | + | ||
| 815 | + for item in items: | ||
| 816 | + if isinstance(item, (BaseIndexEntry, (Blob, Submodule))): | ||
| 817 | + paths.append(self._to_relative_path(item.path)) | ||
| 818 | + elif isinstance(item, string_types): | ||
| 819 | + paths.append(self._to_relative_path(item)) | ||
| 820 | + else: | ||
| 821 | + raise TypeError("Invalid item type: %r" % item) | ||
| 823 | 822 | # END for each item | |
| 824 | 823 | return paths | |
| 825 | 824 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments