Python path.endswith方法代码示例 您所在的位置:网站首页 Python中endwith的用法 Python path.endswith方法代码示例

Python path.endswith方法代码示例

2024-05-03 01:48| 来源: 网络整理| 查看: 265

本文整理汇总了Python中os.path.endswith方法的典型用法代码示例。如果您正苦于以下问题:Python path.endswith方法的具体用法?Python path.endswith怎么用?Python path.endswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os.path的用法示例。

在下文中一共展示了path.endswith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_command # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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) 开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:27,代码来源:conftest.py 示例2: uninstallation_paths # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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 开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:wheel.py 示例3: __processRemovedDir # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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] 开发者ID:SergeySatskiy,项目名称:codimension,代码行数:19,代码来源:watcher.py 示例4: checkOutsidePathChange # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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 开发者ID:SergeySatskiy,项目名称:codimension,代码行数:19,代码来源:editorsmanager.py 示例5: __init__ # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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) 开发者ID:AmesCornish,项目名称:buttersink,代码行数:19,代码来源:SSHStore.py 示例6: run # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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 开发者ID:AmesCornish,项目名称:buttersink,代码行数:23,代码来源:SSHStore.py 示例7: find_address_file # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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] 开发者ID:SvenVD,项目名称:rpisurv,代码行数:18,代码来源:bus_finder.py 示例8: test_just_my_code_debug_option_deprecated # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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 开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:26,代码来源:test_debugger_json.py 示例9: read_test_set # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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) 开发者ID:vecto-ai,项目名称:vecto,代码行数:23,代码来源:synonymy_detection.py 示例10: read_test_set # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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) 开发者ID:vecto-ai,项目名称:vecto,代码行数:22,代码来源:categorization.py 示例11: read_test_set # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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) 开发者ID:vecto-ai,项目名称:vecto,代码行数:23,代码来源:outliers.py 示例12: _get_config # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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) 开发者ID:iRobotCorporation,项目名称:cfn-custom-resource,代码行数:22,代码来源:deployment.py 示例13: test_attributes # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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 开发者ID:RhetTbull,项目名称:osxphotos,代码行数:24,代码来源:test_catalina_10_15_1.py 示例14: test_attributes # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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 开发者ID:RhetTbull,项目名称:osxphotos,代码行数:26,代码来源:test_mojave_10_14_6.py 示例15: test_attributes # 需要导入模块: from os import path [as 别名] # 或者: from os.path import endswith [as 别名] 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 开发者ID:RhetTbull,项目名称:osxphotos,代码行数:24,代码来源:test_catalina_10_15_4.py

注:本文中的os.path.endswith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有