Python os.path.endswith() Examples
The following are 30
code examples of os.path.endswith().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os.path
, or try the search function
.
Example #1
Source File: bus_finder.py From python-omxplayer-wrapper with GNU Lesser General Public License v3.0 | 6 votes |
def find_address_file(self): """ Finds the OMXPlayer DBus connection Assumes there is an alive OMXPlayer process. :return: """ possible_address_files = [] while not possible_address_files: # filter is used here as glob doesn't support regexp :( isnt_pid_file = lambda path: not path.endswith('.pid') possible_address_files = list(filter(isnt_pid_file, glob('/tmp/omxplayerdbus.*'))) possible_address_files.sort(key=lambda path: os.path.getmtime(path)) time.sleep(0.05) self.path = possible_address_files[-1]
Example #2
Source File: editorsmanager.py From codimension with GNU General Public License v3.0 | 6 votes |
def checkOutsidePathChange(self, path): """Checks outside changes for a certain path""" if path.endswith(os.path.sep): return for index in range(self.count()): widget = self.widget(index) fileName = widget.getFileName() if fileName == path: self._updateIconAndTooltip(index) currentWidget = self.currentWidget() if currentWidget == widget: if widget.doesFileExist(): if not widget.getReloadDialogShown(): widget.showOutsideChangesBar( self.__countDiskModifiedUnchanged() > 1) break
Example #3
Source File: watcher.py From codimension with GNU General Public License v3.0 | 6 votes |
def __processRemovedDir(self, path, dirsToBeRemoved, itemsToReport): """called for a disappeared dir in the project tree""" # it should remove the dirs recursively from the fs snapshot # and care of items to report dirsToBeRemoved.append(path) itemsToReport.append("-" + path) oldSet = self.__fsSnapshot[path] for item in oldSet: if item.endswith(os.path.sep): # Nested dir self.__processRemovedDir(path + item, dirsToBeRemoved, itemsToReport) else: # a file itemsToReport.append("-" + path + item) del self.__fsSnapshot[path]
Example #4
Source File: wheel.py From recruit with Apache License 2.0 | 6 votes |
def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path
Example #5
Source File: wheel.py From jbox with MIT License | 6 votes |
def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path
Example #6
Source File: wheel.py From python-netsurv with MIT License | 6 votes |
def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path
Example #7
Source File: wheel.py From python-netsurv with MIT License | 6 votes |
def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path
Example #8
Source File: wheel.py From kobo-predict with BSD 2-Clause "Simplified" License | 6 votes |
def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path
Example #9
Source File: wheel.py From vnpy_crypto with MIT License | 6 votes |
def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path
Example #10
Source File: SSHStore.py From buttersink with GNU General Public License v3.0 | 6 votes |
def __init__(self, host, path, mode, dryrun): """ Initialize. :arg host: ssh host. """ # For simplicity, only allow absolute paths # Don't lose a trailing slash -- it's significant path = "/" + os.path.normpath(path) + ("/" if path.endswith("/") else "") super(SSHStore, self).__init__(host, path, mode, dryrun) self.host = host self._client = _Client(host, 'r' if dryrun else mode, path) self.isRemote = True self.toArg = _Obj2Arg() self.toObj = _Dict2Obj(self)
Example #11
Source File: SSHStore.py From buttersink with GNU General Public License v3.0 | 6 votes |
def run(self): """ Run the server. Returns with system error code. """ normalized = os.path.normpath(self.path) + ("/" if self.path.endswith("/") else "") if self.path != normalized: sys.stderr.write("Please use full path '%s'" % (normalized,)) return -1 self.butterStore = ButterStore.ButterStore(None, self.path, self.mode, dryrun=False) # self.butterStore.ignoreExtraVolumes = True self.toObj = _Arg2Obj(self.butterStore) self.toDict = _Obj2Dict() self.running = True with self.butterStore: with self: while self.running: self._processCommand() return 0
Example #12
Source File: bus_finder.py From rpisurv with GNU General Public License v2.0 | 6 votes |
def find_address_file(self): """ Finds the OMXPlayer DBus connection Assumes there is an alive OMXPlayer process. :return: """ possible_address_files = [] while not possible_address_files: # filter is used here as glob doesn't support regexp :( isnt_pid_file = lambda path: not path.endswith('.pid') possible_address_files = list(filter(isnt_pid_file, glob('/tmp/omxplayerdbus.*'))) possible_address_files.sort(key=lambda path: os.path.getmtime(path)) time.sleep(0.05) self.path = possible_address_files[-1]
Example #13
Source File: test_debugger_json.py From PyDev.Debugger with Eclipse Public License 1.0 | 6 votes |
def test_just_my_code_debug_option_deprecated(case_setup, debug_stdlib, debugger_runner_simple): from _pydev_bundle import pydev_log with case_setup.test_file('_debugger_case_debug_options.py') as writer: json_facade = JsonFacade(writer) json_facade.write_launch( redirectOutput=True, # Always redirect the output regardless of other values. debugStdLib=debug_stdlib ) json_facade.write_make_initial_run() output = json_facade.wait_for_json_message( OutputEvent, lambda msg: msg.body.category == 'stdout' and msg.body.output.startswith('{')and msg.body.output.endswith('}')) settings = json.loads(output.body.output) # Note: the internal attribute is just_my_code. assert settings['just_my_code'] == (not debug_stdlib) json_facade.wait_for_terminated() contents = [] for f in pydev_log.list_log_files(debugger_runner_simple.pydevd_debug_file): if os.path.exists(f): with open(f, 'r') as stream: contents.append(stream.read()) writer.finished_ok = True
Example #14
Source File: wheel.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path
Example #15
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def run_command(quteproc, server, tmpdir, command): """Run a qutebrowser command. The suffix "with count ..." can be used to pass a count to the command. """ if 'with count' in command: command, count = command.split(' with count ') count = int(count) else: count = None invalid_tag = ' (invalid command)' if command.endswith(invalid_tag): command = command[:-len(invalid_tag)] invalid = True else: invalid = False command = command.replace('(port)', str(server.port)) command = command.replace('(testdata)', testutils.abs_datapath()) command = command.replace('(tmpdir)', str(tmpdir)) command = command.replace('(dirsep)', os.sep) command = command.replace('(echo-exe)', _get_echo_exe_path()) quteproc.send_cmd(command, count=count, invalid=invalid)
Example #16
Source File: fs.py From python-langserver with MIT License | 6 votes |
def listdir(self, path: str, parent_span) -> List[Entry]: if path.endswith('/'): path = path[:-1] path_parts = path.split('/') entries = {} for p, v in self.contents.items(): if not p.startswith(path): continue p_parts = p.split('/') if len(p_parts) <= len(path_parts): continue if p_parts[len(path_parts) - 1] != path_parts[-1]: continue name = p_parts[len(path_parts)] if name in entries: continue is_dir = len(p_parts) > len(path_parts) + 1 size = 0 if is_dir else len(v) entries[name] = Entry(name, is_dir, size) return entries.values() # TODO(aaron): determine whether this extra filesystem is really necessary, or if we could have # just used a local fs I suspect not, because the new workspace indexing/importing code wasn't # written with a local fs in mind
Example #17
Source File: patchcheck.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def travis(pull_request): if pull_request == 'false': print('Not a pull request; skipping') return base_branch = get_base_branch() file_paths = changed_files(base_branch) python_files = [fn for fn in file_paths if fn.endswith('.py')] c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))] doc_files = [fn for fn in file_paths if fn.startswith('Doc') and fn.endswith(('.rst', '.inc'))] fixed = [] fixed.extend(normalize_whitespace(python_files)) fixed.extend(normalize_c_whitespace(c_files)) fixed.extend(normalize_docs_whitespace(doc_files)) if not fixed: print('No whitespace issues found') else: print(f'Please fix the {len(fixed)} file(s) with whitespace issues') print('(on UNIX you can run `make patchcheck` to make the fixes)') sys.exit(1)
Example #18
Source File: test_catalina_10_15_4.py From osxphotos with MIT License | 6 votes |
def test_attributes(): import datetime import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) photos = photosdb.photos(uuid=["D79B8D77-BFFC-460B-9312-034F2877D35B"]) assert len(photos) == 1 p = photos[0] assert p.keywords == ["Kids"] assert p.original_filename == "Pumkins2.jpg" assert p.filename == "D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg" assert p.date == datetime.datetime( 2018, 9, 28, 16, 7, 7, 0, datetime.timezone(datetime.timedelta(seconds=-14400)) ) assert p.description == "Girl holding pumpkin" assert p.title == "I found one!" assert sorted(p.albums) == ["Pumpkin Farm", "Test Album"] assert p.persons == ["Katie"] assert p.path.endswith( "tests/Test-10.15.4.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg" ) assert p.ismissing == False
Example #19
Source File: test_mojave_10_14_6.py From osxphotos with MIT License | 6 votes |
def test_attributes(): import datetime import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) photos = photosdb.photos(uuid=["15uNd7%8RguTEgNPKHfTWw"]) assert len(photos) == 1 p = photos[0] assert p.keywords == ["Kids"] assert p.original_filename == "Pumkins2.jpg" assert p.filename == "Pumkins2.jpg" assert p.date == datetime.datetime( 2018, 9, 28, 16, 7, 7, 0, datetime.timezone(datetime.timedelta(seconds=-14400)) ) assert p.description == "Girl holding pumpkin" assert p.title == "I found one!" assert sorted(p.albums) == sorted( ["Pumpkin Farm", "AlbumInFolder", "Test Album (1)"] ) assert p.persons == ["Katie"] assert p.path.endswith( "/tests/Test-10.14.6.photoslibrary/Masters/2019/07/27/20190727-131650/Pumkins2.jpg" ) assert p.ismissing == False
Example #20
Source File: test_catalina_10_15_1.py From osxphotos with MIT License | 6 votes |
def test_attributes(): import datetime import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) photos = photosdb.photos(uuid=["D79B8D77-BFFC-460B-9312-034F2877D35B"]) assert len(photos) == 1 p = photos[0] assert p.keywords == ["Kids"] assert p.original_filename == "Pumkins2.jpg" assert p.filename == "D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg" assert p.date == datetime.datetime( 2018, 9, 28, 16, 7, 7, 0, datetime.timezone(datetime.timedelta(seconds=-14400)) ) assert p.description == "Girl holding pumpkin" assert p.title == "I found one!" assert sorted(p.albums) == ["Multi Keyword", "Pumpkin Farm", "Test Album"] assert p.persons == ["Katie"] assert p.path.endswith( "tests/Test-10.15.1.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg" ) assert p.ismissing == False
Example #21
Source File: deployment.py From cfn-custom-resource with Mozilla Public License 2.0 | 6 votes |
def _get_config(path): if path.endswith('/'): path = path[:-1] handler_function = 'handler' if os.path.isfile(path): file_name = os.path.basename(path) name = file_name.rsplit('.',1)[0] code_uri = os.path.dirname(path) handler_file = name else: name = os.path.basename(path) code_uri = path for handler_file in [name, 'index', 'handler']: if os.path.isfile(os.path.join(path, '{}.py'.format(handler_file))): break else: raise RuntimeError('No handler file found!') handler = '{}.{}'.format(handler_file, handler_function) return _config(name, code_uri, handler)
Example #22
Source File: outliers.py From vecto with Mozilla Public License 2.0 | 6 votes |
def read_test_set(self, path): test = defaultdict(lambda: []) if path.endswith('.csv'): with open(path, 'r') as csvfile: reader = csv.reader(csvfile) head = True for row in reader: if len(row) < 3: continue if not head: category = row[1] word = row[2] is_outlier = row[3] test[category].append({'word': word, 'is_outlier': is_outlier}) head = False else: with open(path) as f: for line in f: _, category, word, is_outlier = line.strip().split() test[category].append({'word': word, 'is_outlier': is_outlier}) return dict(test)
Example #23
Source File: categorization.py From vecto with Mozilla Public License 2.0 | 6 votes |
def read_test_set(self, path): test = defaultdict(lambda: []) if path.endswith('.csv'): with open(path, 'r') as csvfile: reader = csv.reader(csvfile) head = True for row in reader: if len(row) < 2: continue if not head: category = row[1] word = row[2] test[category].append(word) head = False else: with open(path) as f: for line in f: id, category, word = line.strip().split() test[category].append(word) return dict(test)
Example #24
Source File: synonymy_detection.py From vecto with Mozilla Public License 2.0 | 6 votes |
def read_test_set(self, path): data = defaultdict(lambda: []) if path.endswith('.csv'): with open(path, 'r') as csvfile: reader = csv.reader(csvfile) head = True for row in reader: if len(row) < 3: continue if not head: target_word = row[1] word = row[2] is_synonym = row[3] data[target_word].append([word, is_synonym]) head = False else: with open(path) as f: for line in f: _, target_word, word, is_synonym = line.strip().split() data[target_word].append([word, is_synonym]) return dict(data)
Example #25
Source File: wheel.py From anpr with Creative Commons Attribution 4.0 International | 6 votes |
def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.utils import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base + '.pyc') yield path
Example #26
Source File: test_catalina_10_15_1.py From osxphotos with MIT License | 5 votes |
def test_path_edited1(): # test a valid edited path import os.path import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) photos = photosdb.photos(uuid=["E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51"]) assert len(photos) == 1 p = photos[0] path = p.path_edited assert path.endswith( "resources/renders/E/E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51_1_201_a.jpeg" ) assert os.path.exists(path)
Example #27
Source File: IkaWatcher.py From IkaLog with Apache License 2.0 | 5 votes |
def on_modified(self, event): path = event.src_path if not path.endswith(self._video_ext): return print('%s: on_modified(%s)' % (get_time(time.time()), path)) print_file_info(path) self._video_queue.put(path)
Example #28
Source File: IkaWatcher.py From IkaLog with Apache License 2.0 | 5 votes |
def on_deleted(self, event): path = event.src_path if not path.endswith(self._video_ext): return print('%s: on_deleted(%s)' % (get_time(time.time()), path))
Example #29
Source File: test_catalina_10_15_1.py From osxphotos with MIT License | 5 votes |
def test_get_library_path(): import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) lib_path = photosdb.library_path assert lib_path.endswith(PHOTOS_LIBRARY_PATH)
Example #30
Source File: test_mojave_10_14_6_path_edited.py From osxphotos with MIT License | 5 votes |
def test_path_edited1(): # test a valid edited path import os.path import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) photos = photosdb.photos(uuid=[UUID_DICT["standard_00_path"]]) assert len(photos) == 1 p = photos[0] path = p.path_edited assert path.endswith("resources/media/version/00/00/fullsizeoutput_d.jpeg") assert os.path.exists(path)