当前位置: 首页>>代码示例>>Python>>正文


Python path.lexists方法代码示例

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


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

示例1: merge

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lexists [as 别名]
def merge(merged: Path, chunk: Path):
    logger = get_logger()
    logger.info(f"Merging {chunk} into {merged}")
    if lexists(merged):
        logger.info("DB size before: %s items %d bytes", entries(merged), merged.stat().st_size)
    else:
        logger.info(f"DB doesn't exist yet: {merged}")

    candidates = []
    for ff in [chrome, firefox, firefox_phone]:
        res = sqlite(chunk, f"SELECT * FROM {ff.detector}", method=subprocess.run, stdout=DEVNULL, stderr=DEVNULL)
        if res.returncode == 0:
            candidates.append(ff)
    assert len(candidates) == 1
    merger = candidates[0]

    merge_browser(merged=merged, chunk=chunk, schema=merger.schema, schema_check=merger.schema_check, query=merger.query)
    logger.info("DB size after : %s items %d bytes", entries(merged), merged.stat().st_size) 
开发者ID:karlicoss,项目名称:promnesia,代码行数:20,代码来源:populate-browser-history.py

示例2: fixate

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lexists [as 别名]
def fixate():
    "puts activation code to usercustomize.py for user"
    print_message('Fixate')
    import site
    userdir = site.getusersitepackages()
    if not userdir:
        raise PundleException('Can`t fixate due user have not site package directory')
    try:
        makedirs(userdir)
    except OSError:
        pass
    template = FIXATE_TEMPLATE.replace('op.dirname(__file__)', "'%s'" % op.abspath(op.dirname(__file__)))
    usercustomize_file = op.join(userdir, 'usercustomize.py')
    print_message('Will edit %s file' % usercustomize_file)
    if op.exists(usercustomize_file):
        content = open(usercustomize_file).read()
        if '# pundle user customization start' in content:
            regex = re.compile(r'\n# pundle user customization start.*# pundle user customization end\n', re.DOTALL)
            content, res = regex.subn(template, content)
            open(usercustomize_file, 'w').write(content)
        else:
            open(usercustomize_file, 'a').write(content)
    else:
        open(usercustomize_file, 'w').write(template)
    link_file = op.join(userdir, 'pundle.py')
    if op.lexists(link_file):
        print_message('Remove exist link to pundle')
        os.unlink(link_file)
    print_message('Create link to pundle %s' % link_file)
    os.symlink(op.abspath(__file__), link_file)
    print_message('Complete') 
开发者ID:Deepwalker,项目名称:pundler,代码行数:33,代码来源:pundle.py

示例3: lexists

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lexists [as 别名]
def lexists(path=("StringPin", "", {PinSpecifires.INPUT_WIDGET_VARIANT: "PathWidget"})):
        '''Return True if path refers to an existing path. Returns True for broken symbolic links. Equivalent to exists() on platforms lacking os.lstat().'''
        return osPath.lexists(path) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:5,代码来源:PathLib.py

示例4: prep_symlink

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lexists [as 别名]
def prep_symlink(outdir, workdir, filename=None):
    """ Creates a symlink between outdir and workdir.

        If outdir and workdir are the same directory, then bails out.
        Both directories should exist prior to call.
        If filename is None, then creates a symlink to workdir in outdir called
        ``workdir``. Otherwise, creates a symlink in workdir called filename.
        If a link ``filename`` already exists, deletes it first.
    """
    from os import remove, symlink
    from os.path import samefile, lexists, abspath, join
    from ..misc import chdir
    if samefile(outdir, workdir):
        return
    if filename is None:
        with chdir(workdir):
            if lexists('workdir'):
                try:
                    remove('workdir')
                except OSError:
                    pass
            try:
                symlink(abspath(workdir), abspath(join(outdir, 'workdir')))
            except OSError:
                pass
        return

    with chdir(workdir):
        if lexists(filename):
            try:
                remove(filename)
            except OSError:
                pass
        try:
            symlink(abspath(join(outdir, filename)),
                    abspath(join(workdir, filename)))
        except OSError:
            pass 
开发者ID:pylada,项目名称:pylada-light,代码行数:40,代码来源:__init__.py

示例5: _test_merge_all_from

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lexists [as 别名]
def _test_merge_all_from(tdir):
    merge_all_from = backup_db.merge_all_from # type: ignore
    mdir = join(tdir, 'merged')
    mkdir(mdir)
    mfile = join(mdir, 'merged.sql')

    get_chrome_history_backup(tdir)

    merge_all_from(mfile, join(tdir, 'backup'), None)

    first  = join(tdir, "backup/20180415/History")
    second = join(tdir, "backup/20180417/History")

    # should be removed
    assert not lexists(first)
    assert not lexists(second)

    import promnesia.sources.chrome as chrome_ex

    hist = history(W(chrome_ex.extract, mfile))
    assert len(hist) > 0

    older = hist['github.com/orgzly/orgzly-android/issues']
    assert any(v.dt.date() < date(year=2018, month=1, day=17) for v in older)
    # in particular, "2018-01-16 19:56:56"

    newer = hist['en.wikipedia.org/wiki/Notice_and_take_down']
    assert any(v.dt.date() >= date(year=2018, month=4, day=16) for v in newer)

    # from implicit db
    newest = hist['feedly.com/i/discover']
    assert any(v.dt.date() >= date(year=2018, month=9, day=27) for v in newest) 
开发者ID:karlicoss,项目名称:promnesia,代码行数:34,代码来源:indexer_test.py

示例6: _quit_if_exists

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lexists [as 别名]
def _quit_if_exists(m: pdoc.Module, ext: str):
    if args.force:
        return

    paths = [module_path(m, ext)]
    if m.is_package:  # If package, make sure the dir doesn't exist either
        paths.append(path.dirname(paths[0]))

    for pth in paths:
        if path.lexists(pth):
            print("File '%s' already exists. Delete it, or run with --force" % pth,
                  file=sys.stderr)
            sys.exit(1) 
开发者ID:pdoc3,项目名称:pdoc,代码行数:15,代码来源:cli.py


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