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


Python path.abspath函数代码示例

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


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

示例1: check_mask_coverage

def check_mask_coverage(epi,brainmask):
    from os.path import abspath
    from nipype import config, logging
    config.enable_debug_mode()
    logging.update_logging(config)
    from nilearn import plotting
    from nipype.interfaces.nipy.preprocess import Trim

    trim = Trim()
    trim.inputs.in_file = epi
    trim.inputs.end_index = 1
    trim.inputs.out_file = 'epi_vol1.nii.gz'
    trim.run()
    epi_vol = abspath('epi_vol1.nii.gz')

    maskcheck_filename='maskcheck.png'
    display = plotting.plot_anat(epi_vol, display_mode='ortho',
                                 draw_cross=False,
                                 title = 'brainmask coverage')
    display.add_contours(brainmask,levels=[.5], colors='r')
    display.savefig(maskcheck_filename)
    display.close()
    maskcheck_file = abspath(maskcheck_filename)

    return(maskcheck_file)
开发者ID:catcamacho,项目名称:infant_rest,代码行数:25,代码来源:preprocessing_classic.py

示例2: find_pylintrc

def find_pylintrc():
    """search the pylint rc file and return its path if it find it, else None
    """
    # is there a pylint rc file in the current directory ?
    if exists("pylintrc"):
        return abspath("pylintrc")
    if isfile("__init__.py"):
        curdir = abspath(os.getcwd())
        while isfile(join(curdir, "__init__.py")):
            curdir = abspath(join(curdir, ".."))
            if isfile(join(curdir, "pylintrc")):
                return join(curdir, "pylintrc")
    if "PYLINTRC" in os.environ and exists(os.environ["PYLINTRC"]):
        pylintrc = os.environ["PYLINTRC"]
    else:
        user_home = expanduser("~")
        if user_home == "~" or user_home == "/root":
            pylintrc = ".pylintrc"
        else:
            pylintrc = join(user_home, ".pylintrc")
            if not isfile(pylintrc):
                pylintrc = join(user_home, ".config", "pylintrc")
    if not isfile(pylintrc):
        if isfile("/etc/pylintrc"):
            pylintrc = "/etc/pylintrc"
        else:
            pylintrc = None
    return pylintrc
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:28,代码来源:config.py

示例3: results_table

def results_table(path_dict):
    """ Return precalculated results images for subject info in `path_dict`

    Parameters
    ----------
    path_dict : dict
        containing key 'rootdir'

    Returns
    -------
    rtab : dict
        dict with keys given by run directories for this subject, values being a
        list with filenames of effect and sd images.
    """
    # Which runs correspond to this design type?
    rootdir = path_dict['rootdir']
    runs = filter(lambda f: isdir(pjoin(rootdir, f)),
                  ['results_%02d' % i for i in range(1,5)] )

    # Find out which contrasts have t-statistics,
    # storing the filenames for reading below

    results = {}

    for rundir in runs:
        rundir = pjoin(rootdir, rundir)
        for condir in listdir(rundir):
            for stat in ['sd', 'effect']:
                fname_effect = abspath(pjoin(rundir, condir, 'effect.nii'))
                fname_sd = abspath(pjoin(rundir, condir, 'sd.nii'))
            if exists(fname_effect) and exists(fname_sd):
                results.setdefault(condir, []).append([fname_effect,
                                                       fname_sd])
    return results
开发者ID:GaelVaroquaux,项目名称:nipy,代码行数:34,代码来源:fiac_util.py

示例4: inside

def inside(dir, name):
    """
    检查给定的目录中是否有给定的文件名。
    """
    dir = abspath(dir)
    name = abspath(name)
    return name.startswith(join(dir, ''))
开发者ID:DerekChenGit,项目名称:p2pFilesManager,代码行数:7,代码来源:server.py

示例5: check_filepath

def check_filepath(filepath):
	if not filepath:
		return None
	
	base_filename = basename(filepath)
	abs_dirname = dirname(abspath(filepath)) if base_filename else abspath(filepath)
	return join(abs_dirname, base_filename)
开发者ID:Auzzy,项目名称:personal,代码行数:7,代码来源:main.py

示例6: check

    def check(self):
        """ Checks parameters and paths
        """

        if 'TITLE' not in PAR:
            setattr(PAR, 'TITLE', unix.basename(abspath('..')))

        if 'SUBTITLE' not in PAR:
            setattr(PAR, 'SUBTITLE', unix.basename(abspath('.')))

        # check parameters
        if 'NTASK' not in PAR:
            setattr(PAR, 'NTASK', 1)

        if 'NPROC' not in PAR:
            setattr(PAR, 'NPROC', 1)

        if 'VERBOSE' not in PAR:
            setattr(PAR, 'VERBOSE', 1)

        # check paths
        if 'GLOBAL' not in PATH:
            setattr(PATH, 'GLOBAL', join(abspath('.'), 'scratch'))

        if 'LOCAL' not in PATH:
            setattr(PATH, 'LOCAL', '')

        if 'SUBMIT' not in PATH:
            setattr(PATH, 'SUBMIT', unix.pwd())

        if 'OUTPUT' not in PATH:
            setattr(PATH, 'OUTPUT', join(PATH.SUBMIT, 'output'))

        if 'SYSTEM' not in PATH:
            setattr(PATH, 'SYSTEM', join(PATH.GLOBAL, 'system'))
开发者ID:AlainPlattner,项目名称:seisflows,代码行数:35,代码来源:serial.py

示例7: getIcons

def getIcons(filename=None):
    """Creates wxBitmaps ``self.icon`` and ``self.iconAdd`` based on the the image.
    The latter has a plus sign added over the top.

    png files work best, but anything that wx.Image can import should be fine
    """
    icons = {}
    if filename is None:
        filename = join(dirname(abspath(__file__)), 'base.png')
        
    # get the low-res version first
    im = Image.open(filename)
    icons['24'] = pilToBitmap(im, scaleFactor=0.5)
    icons['24add'] = pilToBitmap(im, scaleFactor=0.5)
    # try to find a 128x128 version
    filename128 = filename[:-4]+'128.png'
    if False: # TURN OFF FOR NOW os.path.isfile(filename128):
        im = Image.open(filename128)
    else:
        im = Image.open(filename)
    icons['48'] = pilToBitmap(im)
    # add the plus sign
    add = Image.open(join(dirname(abspath(__file__)), 'add.png'))
    im.paste(add, [0, 0, add.size[0], add.size[1]], mask=add)
    # im.paste(add, [im.size[0]-add.size[0], im.size[1]-add.size[1],
    #               im.size[0], im.size[1]], mask=add)
    icons['48add'] = pilToBitmap(im)

    return icons
开发者ID:andela-dowoade,项目名称:psychopy,代码行数:29,代码来源:__init__.py

示例8: copy_strip

def copy_strip():
    """Copy idle.html to idlelib/help.html, stripping trailing whitespace.

    Files with trailing whitespace cannot be pushed to the hg cpython
    repository.  For 3.x (on Windows), help.html is generated, after
    editing idle.rst in the earliest maintenance version, with
      sphinx-build -bhtml . build/html
      python_d.exe -c "from idlelib.help import copy_strip; copy_strip()"
    After refreshing TortoiseHG workshop to generate a diff,
    check  both the diff and displayed text.  Push the diff along with
    the idle.rst change and merge both into default (or an intermediate
    maintenance version).

    When the 'earlist' version gets its final maintenance release,
    do an update as described above, without editing idle.rst, to
    rebase help.html on the next version of idle.rst.  Do not worry
    about version changes as version is not displayed.  Examine other
    changes and the result of Help -> IDLE Help.

    If maintenance and default versions of idle.rst diverge, and
    merging does not go smoothly, then consider generating
    separate help.html files from separate idle.htmls.
    """
    src = join(abspath(dirname(dirname(dirname(__file__)))),
               'Doc', 'build', 'html', 'library', 'idle.html')
    dst = join(abspath(dirname(__file__)), 'help.html')
    with open(src, 'rb') as inn,\
         open(dst, 'wb') as out:
        for line in inn:
            out.write(line.rstrip() + b'\n')
    print('idle.html copied to help.html')
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:31,代码来源:help.py

示例9: test_reset_files

 def test_reset_files(self):
     """reset files"""
     for document in self.documents:
         document.share_file(abspath("data"), True)
         self.assertEquals(document.get_container(abspath("data"))._shared, True)
         document.reset_files()
         self.assertEquals(document.get_files(), {})
开发者ID:BackupTheBerlios,项目名称:solipsis-svn,代码行数:7,代码来源:unittest_document.py

示例10: test_get_home_dir_7

def test_get_home_dir_7():
    """Using HOMESHARE, os=='nt'."""

    os.name = 'nt'
    env["HOMESHARE"] = abspath(HOME_TEST_DIR)
    home_dir = path.get_home_dir()
    nt.assert_equal(home_dir, abspath(HOME_TEST_DIR))
开发者ID:markvoorhies,项目名称:ipython,代码行数:7,代码来源:test_path.py

示例11: convert_disk_image

def convert_disk_image(args):
    """Convert disk to another format."""
    filename = op.abspath(args.file.name)
    output = op.abspath(args.output)

    os.environ['LIBGUESTFS_CACHEDIR'] = os.getcwd()
    if args.verbose:
        os.environ['LIBGUESTFS_DEBUG'] = '1'

    if args.zerofree:
        guestfish_zerofree(filename)

    for fmt in args.formats:
        if fmt in (tar_formats + disk_formats):
            output_filename = "%s.%s" % (output, fmt)
            if output_filename == filename:
                continue
            logger.info("Creating %s" % output_filename)
            try:
                if fmt in tar_formats:
                    tar_convert(filename, output_filename,
                                args.tar_excludes,
                                args.tar_compression_level)
                else:
                    qemu_convert(filename, fmt, output_filename)
            except ValueError as exp:
                logger.error("Error: %s" % exp)
开发者ID:mickours,项目名称:kameleon-helpers,代码行数:27,代码来源:export_appliance.py

示例12: main

def main():
  """The main function."""
  options = ParseOptions()
  required_flags = ["version_file", "output", "input", "build_dir",
                    "gen_out_dir", "auto_updater_dir", "build_type"]
  for flag in required_flags:
    if getattr(options, flag) is None:
      logging.error("--%s is not specified." % flag)
      exit(-1)

  version = mozc_version.MozcVersion(options.version_file)

  # \xC2\xA9 is the copyright mark in UTF-8
  copyright_message = '\xC2\xA9 %d Google Inc.' % _COPYRIGHT_YEAR
  long_version = version.GetVersionString()
  short_version = version.GetVersionInFormat('@[email protected]@[email protected]@[email protected]')
  variables = {
      'MOZC_VERSIONINFO_MAJOR': version.GetVersionInFormat('@[email protected]'),
      'MOZC_VERSIONINFO_MINOR': version.GetVersionInFormat('@[email protected]'),
      'MOZC_VERSIONINFO_LONG': long_version,
      'MOZC_VERSIONINFO_SHORT': short_version,
      'MOZC_VERSIONINFO_FINDER':
        'Google Japanese Input %s, %s' % (long_version, copyright_message),
      'GEN_OUT_DIR': path.abspath(options.gen_out_dir),
      'BUILD_DIR': path.abspath(options.build_dir),
      'AUTO_UPDATER_DIR': path.abspath(options.auto_updater_dir),
      'MOZC_DIR': path.abspath(path.join(os.getcwd(), ".."))
      }

  open(options.output, 'w').write(
      _RemoveDevOnlyLines(
          _ReplaceVariables(open(options.input).read(), variables),
          options.build_type))
开发者ID:Ranats,项目名称:mozc,代码行数:33,代码来源:tweak_pkgproj.py

示例13: rev_get_dataset_root

def rev_get_dataset_root(path):
    """Return the root of an existent dataset containing a given path

    The root path is returned in the same absolute or relative form
    as the input argument. If no associated dataset exists, or the
    input path doesn't exist, None is returned.

    If `path` is a symlink or something other than a directory, its
    the root dataset containing its parent directory will be reported.
    If none can be found, at a symlink at `path` is pointing to a
    dataset, `path` itself will be reported as the root.
    """
    suffix = '.git'
    altered = None
    if op.islink(path) or not op.isdir(path):
        altered = path
        path = op.dirname(path)
    apath = op.abspath(path)
    # while we can still go up
    while op.split(apath)[1]:
        if op.exists(op.join(path, suffix)):
            return path
        # new test path in the format we got it
        path = op.normpath(op.join(path, os.pardir))
        # no luck, next round
        apath = op.abspath(path)
    # if we applied dirname() at the top, we give it another go with
    # the actual path, if it was itself a symlink, it could be the
    # top-level dataset itself
    if altered and op.exists(op.join(altered, suffix)):
        return altered

    return None
开发者ID:datalad,项目名称:datalad,代码行数:33,代码来源:dataset.py

示例14: syncfiles

def syncfiles(args):
    if len(args) < 3:
        printtofile ('args not enough, need: files src_host dest_hosts')
        return
    dest_hosts = []
    src_host = ''
    files = ast.literal_eval(args[2])
    if len(args) >= 4:
        src_host = args[3]
    if len(args) >= 5:
        dest_hosts = ast.literal_eval(args[4])
    if len(dest_hosts) == 0:
        if len(src_host) == 0:
            dest_hosts = primary_host + replicas_host
        else:
            dest_hosts = replicas_host

    for file in files:
        fullfilepath = ''
        if (src_host == ''):
            fullfilepath = base_dir + '/' + path.abspath(file).replace(path.abspath(local_base), '')
            printtofile ('local to remote : ' + fullfilepath)
        else:
            fullfilepath = base_dir + '/' + file
        for dest_host in dest_hosts:
            dest_host_path = loginuser + '@' + dest_host + ':' + fullfilepath
            if src_host == '':
                # using local file
                os.system(scp_local + file + ' ' + dest_host_path)
            else:
                os.system(scp_remote + src_host + ':' + fullfilepath + ' ' + dest_host_path)
    printtofile ('finished.')
开发者ID:izenecloud,项目名称:driver-ruby,代码行数:32,代码来源:easy_tool.py

示例15: test_get_shared_files

 def test_get_shared_files(self):
     document = CacheDocument()
     document.add_repository(TEST_DIR)
     document.expand_dir(abspath("data"))
     document.expand_dir(abspath(os.path.join("data", "subdir1")))
     document.share_files(abspath("data"),
                           [os.sep.join([TEST_DIR, "data", ".path"]),
                            os.sep.join([TEST_DIR, "data", ".svn"]),
                            os.sep.join([TEST_DIR, "data", "date.txt"]),
                            os.sep.join([TEST_DIR, "data", "emptydir"]),
                            os.sep.join([TEST_DIR, "data", "profiles"]),
                            os.sep.join([TEST_DIR, "data", "subdir1", ".svn"]),
                            os.sep.join([TEST_DIR, "data", "subdir1", "subsubdir"])],
                           False)
     document.share_files(abspath("data"),
                           [os.sep.join([TEST_DIR, "data"]),
                            os.sep.join([TEST_DIR, "data", ".path"]),
                            os.sep.join([TEST_DIR, "data", "date.txt"]),
                            os.sep.join([TEST_DIR, "data", "routage"]),
                            os.sep.join([TEST_DIR, "data", "subdir1"]),
                            os.sep.join([TEST_DIR, "data", "subdir1", "TOtO.txt"]),
                            os.sep.join([TEST_DIR, "data", "subdir1", "date.doc"])],
                           True)
     shared_files = [file_container.get_path() for file_container
                     in document.get_shared_files()[TEST_DIR]]
     shared_files.sort()
     self.assertEquals(shared_files, [os.sep.join([TEST_DIR, "data", ".path"]),
                                      os.sep.join([TEST_DIR, "data", "02_b_1280x1024.jpg"]),
                                      os.sep.join([TEST_DIR, "data", "Python-2.3.5.zip"]),
                                      os.sep.join([TEST_DIR, "data", "arc en ciel 6.gif"]),
                                      os.sep.join([TEST_DIR, "data", "date.txt"]),
                                      os.sep.join([TEST_DIR, "data", "pywin32-203.win32-py2.3.exe"]),
                                      os.sep.join([TEST_DIR, "data", "routage"]),
                                      os.sep.join([TEST_DIR, "data", "subdir1", "TOtO.txt"]),
                                      os.sep.join([TEST_DIR, "data", "subdir1", "date.doc"])])
开发者ID:BackupTheBerlios,项目名称:solipsis-svn,代码行数:35,代码来源:unittest_document.py


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