Python os.path.abspath() Examples

The following are 30 code examples for showing how to use os.path.abspath(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module os.path , or try the search function .

Example 1
Project: alibuild   Author: alisw   File: test_workarea.py    License: GNU General Public License v3.0 7 votes vote down vote up
def test_referenceSourceExistsNonWriteable(self, mock_is_writeable, mock_os, mock_debug, mock_path, mock_execute, mock_getstatusoutput):
      # Reference sources exists but cannot be written
      # The reference repo is set nevertheless but not updated
      mock_path.exists.side_effect = lambda x: True
      mock_is_writeable.side_effect = lambda x: False
      mock_os.path.join.side_effect = join
      mock_getstatusoutput.side_effect = allow_directory_creation
      mock_git_clone = MagicMock(return_value=None)
      mock_git_fetch = MagicMock(return_value=None)
      mock_execute.side_effect = lambda x, **k: allow_git_clone(x, mock_git_clone, mock_git_fetch, *k)
      spec = OrderedDict({"source": "https://github.com/alisw/AliRoot"})
      referenceSources = "sw/MIRROR"
      reference = abspath(referenceSources) + "/aliroot"
      mock_os.makedirs.reset_mock()
      mock_git_clone.reset_mock()
      mock_git_fetch.reset_mock()
      updateReferenceRepoSpec(referenceSources=referenceSources, p="AliRoot", spec=spec, fetch=True)
      mock_os.makedirs.assert_called_with('%s/sw/MIRROR' % getcwd())
      self.assertEqual(mock_git_fetch.call_count, 0, "Expected no calls to git fetch (called %d times instead)" % mock_git_fetch.call_count)
      self.assertEqual(mock_git_clone.call_count, 0, "Expected no calls to git clone (called %d times instead)" % mock_git_clone.call_count)
      self.assertEqual(spec.get("reference"), reference)
      self.assertEqual(True, call('Updating references.') in mock_debug.mock_calls) 
Example 2
Project: hydrus   Author: HTTP-APIs   File: test_pep8.py    License: MIT License 6 votes vote down vote up
def test_pep8(self):
        """Test method to check PEP8 compliance over the entire project."""
        self.file_structure = dirname(dirname(abspath(__file__)))
        print("Testing for PEP8 compliance of python files in {}".format(
            self.file_structure))
        style = pep8.StyleGuide()
        style.options.max_line_length = 100  # Set this to desired maximum line length
        filenames = []
        # Set this to desired folder location
        for root, _, files in os.walk(self.file_structure):
            python_files = [f for f in files if f.endswith(
                '.py') and "examples" not in root]
            for file in python_files:
                if len(root.split('samples')) != 2:     # Ignore samples directory
                    filename = '{0}/{1}'.format(root, file)
                    filenames.append(filename)
        check = style.check_files(filenames)
        self.assertEqual(check.total_errors, 0, 'PEP8 style errors: %d' %
                         check.total_errors) 
Example 3
Project: alibuild   Author: alisw   File: test_workarea.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_referenceSourceExistsWriteable(self, mock_is_writeable, mock_os, mock_debug, mock_path, mock_execute, mock_getstatusoutput):
      # Reference sources exists and can be written
      # The reference repo is set nevertheless but not updated
      mock_path.exists.side_effect = lambda x: True
      mock_is_writeable.side_effect = lambda x: True
      mock_os.path.join.side_effect = join
      mock_getstatusoutput.side_effect = allow_directory_creation
      mock_git_clone = MagicMock(return_value=None)
      mock_git_fetch = MagicMock(return_value=None)
      mock_execute.side_effect = lambda x, **k: allow_git_clone(x, mock_git_clone, mock_git_fetch, *k)
      spec = OrderedDict({"source": "https://github.com/alisw/AliRoot"})
      referenceSources = "sw/MIRROR"
      reference = abspath(referenceSources) + "/aliroot"
      mock_os.makedirs.reset_mock()
      mock_git_clone.reset_mock()
      mock_git_fetch.reset_mock()
      updateReferenceRepoSpec(referenceSources=referenceSources, p="AliRoot", spec=spec, fetch=True)
      mock_os.makedirs.assert_called_with('%s/sw/MIRROR' % getcwd())
      self.assertEqual(mock_git_fetch.call_count, 1, "Expected one call to git fetch (called %d times instead)" % mock_git_fetch.call_count)
      self.assertEqual(mock_git_clone.call_count, 0, "Expected no calls to git clone (called %d times instead)" % mock_git_clone.call_count)
      self.assertEqual(spec.get("reference"), reference)
      self.assertEqual(True, call('Updating references.') in mock_debug.mock_calls) 
Example 4
Project: alibuild   Author: alisw   File: test_workarea.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_referenceBasedirExistsWriteable(self, mock_is_writeable, mock_os, mock_debug, mock_path, mock_execute, mock_getstatusoutput):
      """
      The referenceSources directory exists and it's writeable
      Reference sources are already there
      """
      mock_path.exists.side_effect = lambda x: True
      mock_is_writeable.side_effect = lambda x: True
      mock_os.path.join.side_effect = join
      mock_getstatusoutput.side_effect = allow_directory_creation
      mock_git_clone = MagicMock(return_value=None)
      mock_git_fetch = MagicMock(return_value=None)
      mock_execute.side_effect = lambda x, **k: allow_git_clone(x, mock_git_clone, mock_git_fetch, *k)
      spec = OrderedDict({"source": "https://github.com/alisw/AliRoot"})
      referenceSources = "sw/MIRROR"
      reference = abspath(referenceSources) + "/aliroot"
      mock_os.makedirs.reset_mock()
      mock_git_clone.reset_mock()
      mock_git_fetch.reset_mock()
      updateReferenceRepo(referenceSources=referenceSources, p="AliRoot", spec=spec)
      mock_os.makedirs.assert_called_with('%s/sw/MIRROR' % getcwd())
      self.assertEqual(mock_git_fetch.call_count, 1, "Expected one call to git fetch (called %d times instead)" % mock_git_fetch.call_count) 
Example 5
Project: alibuild   Author: alisw   File: test_workarea.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_referenceBasedirNotExistsWriteable(self, mock_is_writeable, mock_os, mock_debug, mock_path, mock_execute, mock_getstatusoutput):
      """
      The referenceSources directory exists and it's writeable
      Reference sources are not already there
      """
      mock_path.exists.side_effect = reference_sources_do_not_exists
      mock_is_writeable.side_effect = lambda x: False # not writeable
      mock_os.path.join.side_effect = join
      mock_os.makedirs.side_effect = lambda x: True
      mock_getstatusoutput.side_effect = allow_directory_creation
      mock_git_clone = MagicMock(return_value=None)
      mock_git_fetch = MagicMock(return_value=None)
      mock_execute.side_effect = lambda x, **k: allow_git_clone(x, mock_git_clone, mock_git_fetch, *k)
      spec = OrderedDict({"source": "https://github.com/alisw/AliRoot"})
      referenceSources = "sw/MIRROR"
      reference = abspath(referenceSources) + "/aliroot"
      mock_os.makedirs.reset_mock()
      mock_git_clone.reset_mock()
      mock_git_fetch.reset_mock()
      updateReferenceRepo(referenceSources=referenceSources, p="AliRoot", spec=spec)
      mock_path.exists.assert_called_with('%s/sw/MIRROR/aliroot' % getcwd())
      mock_os.makedirs.assert_called_with('%s/sw/MIRROR' % getcwd())
      self.assertEqual(mock_git_clone.call_count, 0, "Expected no calls to git clone (called %d times instead)" % mock_git_clone.call_count) 
Example 6
Project: alibuild   Author: alisw   File: test_workarea.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_referenceSourceNotExistsWriteable(self, mock_is_writeable, mock_os, mock_debug, mock_path, mock_execute, mock_getstatusoutput):
      """
      The referenceSources directory does not exist and it's writeable
      Reference sources are not already there
      """
      mock_path.exists.side_effect = reference_sources_do_not_exists
      mock_is_writeable.side_effect = lambda x: True  # is writeable
      mock_os.path.join.side_effect = join
      mock_os.makedirs.side_effect = lambda x: True
      mock_getstatusoutput.side_effect = allow_directory_creation
      mock_git_clone = MagicMock(return_value=None)
      mock_git_fetch = MagicMock(return_value=None)
      mock_execute.side_effect = lambda x, **k: allow_git_clone(x, mock_git_clone, mock_git_fetch, *k)
      spec = OrderedDict({"source": "https://github.com/alisw/AliRoot"})
      referenceSources = "sw/MIRROR"
      reference = abspath(referenceSources) + "/aliroot"
      mock_os.makedirs.reset_mock()
      mock_git_clone.reset_mock()
      mock_git_fetch.reset_mock()
      updateReferenceRepo(referenceSources=referenceSources, p="AliRoot", spec=spec)
      mock_path.exists.assert_called_with('%s/sw/MIRROR/aliroot' % getcwd())
      mock_os.makedirs.assert_called_with('%s/sw/MIRROR' % getcwd())
      self.assertEqual(mock_git_clone.call_count, 1, "Expected only one call to git clone (called %d times instead)" % mock_git_clone.call_count) 
Example 7
Project: aws-ops-automator   Author: awslabs   File: __init__.py    License: Apache License 2.0 6 votes vote down vote up
def all_handlers():
    global __actions
    if __actions is None:
        __actions = []
        current = abspath(os.getcwd())
        while True:
            if isdir(os.path.join(current, "handlers")):
                break
            parent = dirname(current)
            if parent == current:
                # at top level
                raise Exception("Could not find handlers directory")
            else:
                current = parent

        for f in listdir(os.path.join(current, "handlers")):
            if isfile(join(current, "handlers", f)) and f.endswith("_{}.py".format(HANDLER.lower())):
                module_name = HANDLERS_MODULE_NAME.format(f[0:-len(".py")])
                m = _get_module(module_name)
                cls = _get_handler_class(m)
                if cls is not None:
                    handler_name = cls[0]
                    __actions.append(handler_name)
    return __actions 
Example 8
Project: pyscf   Author: pyscf   File: test_0091_tddft_x_zip_na20.py    License: Apache License 2.0 6 votes vote down vote up
def test_x_zip_feature_na20_chain(self):
    """ This a test for compression of the eigenvectos at higher energies """
    dname = dirname(abspath(__file__))
    siesd = dname+'/sodium_20'
    x = td_c(label='siesta', cd=siesd,x_zip=True, x_zip_emax=0.25,x_zip_eps=0.05,jcutoff=7,xc_code='RPA',nr=128, fermi_energy=-0.0913346431431985)
    
    eps = 0.005
    ww = np.arange(0.0, 0.5, eps/2.0)+1j*eps
    data = np.array([ww.real*27.2114, -x.comp_polariz_inter_ave(ww).imag])
    fname = 'na20_chain.tddft_iter_rpa.omega.inter.ave.x_zip.txt'
    np.savetxt(fname, data.T, fmt=['%f','%f'])
    #print(__file__, fname)
    data_ref = np.loadtxt(dname+'/'+fname+'-ref')
    #print('    x.rf0_ncalls ', x.rf0_ncalls)
    #print(' x.matvec_ncalls ', x.matvec_ncalls)
    self.assertTrue(np.allclose(data_ref,data.T, rtol=1.0e-1, atol=1e-06)) 
Example 9
Project: pyscf   Author: pyscf   File: test_0004_vna.py    License: Apache License 2.0 6 votes vote down vote up
def test_vna_lih(self):
    dname = dirname(abspath(__file__))
    n = nao(label='lih', cd=dname)
    m = 200
    dvec,midv = 2*(n.atom2coord[1] - n.atom2coord[0])/m,  (n.atom2coord[1] + n.atom2coord[0])/2.0
    vgrid = np.tensordot(np.array(range(-m,m+1)), dvec, axes=0) + midv
    sgrid = np.array(range(-m,m+1)) * np.sqrt((dvec*dvec).sum())
    
    
    #vgrid = np.array([[-1.517908564663352e+00, 1.180550033093826e+00,0.000000000000000e+00]])
    vna = n.vna(vgrid)
    
    #for v,r in zip(vna,vgrid):
    #  print("%23.15e %23.15e %23.15e %23.15e"%(r[0], r[1], r[2], v))
    
    #print(vna.shape, sgrid.shape)
    np.savetxt('vna_lih_0004.txt', np.row_stack((sgrid, vna)).T)
    ref = np.loadtxt(dname+'/vna_lih_0004.txt-ref')
    for r,d in zip(ref[:,1],vna): self.assertAlmostEqual(r,d) 
Example 10
Project: ConvLab   Author: ConvLab   File: mdbt.py    License: MIT License 6 votes vote down vote up
def cached_path(file_path, cached_dir=None):
    if not cached_dir:
        cached_dir = str(Path(Path.home() / '.tatk') / "cache")

    return allennlp_cached_path(file_path, cached_dir)

# DATA_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))), 'data/mdbt')
# VALIDATION_URL = os.path.join(DATA_PATH, "data/validate.json")
# WORD_VECTORS_URL = os.path.join(DATA_PATH, "word-vectors/paragram_300_sl999.txt")
# TRAINING_URL = os.path.join(DATA_PATH, "data/train.json")
# ONTOLOGY_URL = os.path.join(DATA_PATH, "data/ontology.json")
# TESTING_URL = os.path.join(DATA_PATH, "data/test.json")
# MODEL_URL = os.path.join(DATA_PATH, "models/model-1")
# GRAPH_URL = os.path.join(DATA_PATH, "graphs/graph-1")
# RESULTS_URL = os.path.join(DATA_PATH, "results/log-1.txt")
# KB_URL = os.path.join(DATA_PATH, "data/")  # TODO: yaoqin
# TRAIN_MODEL_URL = os.path.join(DATA_PATH, "train_models/model-1")
# TRAIN_GRAPH_URL = os.path.join(DATA_PATH, "train_graph/graph-1") 
Example 11
Project: misp42splunk   Author: remg427   File: lib_util.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def register_module(new_path):
    """ register_module(new_path): adds a directory to sys.path.
    Do nothing if it does not exist or if it's already in sys.path.
    """
    if not os.path.exists(new_path):
        return

    new_path = os.path.abspath(new_path)
    if platform.system() == 'Windows':
        new_path = new_path.lower()
    for x in sys.path:
        x = os.path.abspath(x)
        if platform.system() == 'Windows':
            x = x.lower()
        if new_path in (x, x + os.sep):
            return
    sys.path.insert(0, new_path) 
Example 12
Project: misp42splunk   Author: remg427   File: lib_util.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def register_module(new_path):
    """ register_module(new_path): adds a directory to sys.path.
    Do nothing if it does not exist or if it's already in sys.path.
    """
    if not os.path.exists(new_path):
        return

    new_path = os.path.abspath(new_path)
    if platform.system() == 'Windows':
        new_path = new_path.lower()
    for x in sys.path:
        x = os.path.abspath(x)
        if platform.system() == 'Windows':
            x = x.lower()
        if new_path in (x, x + os.sep):
            return
    sys.path.insert(0, new_path) 
Example 13
Project: py   Author: pytest-dev   File: local.py    License: MIT License 6 votes vote down vote up
def __init__(self, path=None, expanduser=False):
        """ Initialize and return a local Path instance.

        Path can be relative to the current directory.
        If path is None it defaults to the current working directory.
        If expanduser is True, tilde-expansion is performed.
        Note that Path instances always carry an absolute path.
        Note also that passing in a local path object will simply return
        the exact same path object. Use new() to get a new copy.
        """
        if path is None:
            self.strpath = py.error.checked_call(os.getcwd)
        else:
            try:
                path = fspath(path)
            except TypeError:
                raise ValueError("can only pass None, Path instances "
                                 "or non-empty strings to LocalPath")
            if expanduser:
                path = os.path.expanduser(path)
            self.strpath = abspath(path) 
Example 14
Project: linter-pylama   Author: AtomLinter   File: main.py    License: MIT License 6 votes vote down vote up
def process_paths(options, candidates=None, error=True):
    """Process files and log errors."""
    errors = check_path(options, rootdir=CURDIR, candidates=candidates)

    if options.format in ['pycodestyle', 'pep8']:
        pattern = "%(filename)s:%(lnum)s:%(col)s: %(text)s"
    elif options.format == 'pylint':
        pattern = "%(filename)s:%(lnum)s: [%(type)s] %(text)s"
    else:  # 'parsable'
        pattern = "%(filename)s:%(lnum)s:%(col)s: [%(type)s] %(text)s"

    for er in errors:
        if options.abspath:
            er._info['filename'] = op.abspath(er.filename)
        LOGGER.warning(pattern, er._info)

    if error:
        sys.exit(int(bool(errors)))

    return errors 
Example 15
Project: moler   Author: nokia   File: cmds_events_doc.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _walk_moler_python_files(path, *args):
    """
    Walk thru directory with commands and search for python source code (except __init__.py)
    Yield relative filepath to parameter path

    :param path: relative path do directory with commands
    :type path:
    :rtype: str
    """
    repo_path = abspath(join(path, '..', '..'))

    observer = "event" if "events" in split(path) else "command"
    print("Processing {}s test from path: '{}'".format(observer, path))

    for (dirpath, _, filenames) in walk(path):
        for filename in filenames:
            if filename.endswith('__init__.py'):
                continue
            if filename.endswith('.py'):
                abs_path = join(dirpath, filename)
                in_moler_path = relpath(abs_path, repo_path)
                yield in_moler_path 
Example 16
Project: rm-protection   Author: alanzchen   File: protect.py    License: MIT License 6 votes vote down vote up
def protect(protect_args=None):
    global c
    flags = ''
    option_end = False
    if not protect_args:
        protect_args = argv[1:]
    for arg in protect_args:
        if arg == '--':
            option_end = True
        elif (arg.startswith("-") and not option_end):
            flags = flags + arg[arg.rfind('-') + 1:]
        elif arg in c.invalid:
            pprint('"." and ".." may not be protected')
        else:
            path = abspath(expv(expu(arg)))
            evalpath = dirname(path) + "/." + basename(path) + c.suffix
            if not exists(path):
                pprint("Warning: " + path + " does not exist")
            with open(evalpath, "w") as f:
                question = input("Question for " + path + ": ")
                answer = input("Answer: ")
                f.write(question + "\n" + answer + "\n" + flags.upper()) 
Example 17
Project: godot-mono-builds   Author: godotengine   File: options.py    License: MIT License 5 votes vote down vote up
def base_opts_from_args(args):
    from os.path import abspath
    return BaseOpts(
        verbose_make = args.verbose_make,
        jobs = args.jobs,
        configure_dir = abspath(args.configure_dir),
        install_dir = abspath(args.install_dir),
        mono_source_root = abspath(args.mono_sources),
        mxe_prefix = args.mxe_prefix
    ) 
Example 18
Project: godot-mono-builds   Author: godotengine   File: options.py    License: MIT License 5 votes vote down vote up
def android_opts_from_args(args):
    return AndroidOpts(
        **vars(runtime_opts_from_args(args)),
        android_toolchains_prefix = abspath(args.toolchains_prefix),
        android_sdk_root = abspath(args.android_sdk),
        android_ndk_root = abspath(args.android_ndk),
        android_api_version = args.android_api_version,
        android_cmake_version = args.android_cmake_version
    ) 
Example 19
Project: godot-mono-builds   Author: godotengine   File: options.py    License: MIT License 5 votes vote down vote up
def ios_opts_from_args(args):
    return iOSOpts(
        **vars(runtime_opts_from_args(args)),
        ios_toolchain_path = abspath(args.ios_toolchain),
        ios_sdk_path = abspath(args.ios_sdk) if args.ios_sdk else '',
        ios_version_min = args.ios_version_min,
        osx_toolchain_path = abspath(args.osx_toolchain),
        osx_sdk_path = abspath(args.osx_sdk) if args.ios_sdk else '',
        osx_triple_abi = args.osx_triple_abi
    ) 
Example 20
def get_output_dir(imdb, weights_filename):
  """Return the directory where experimental artifacts are placed.
  If the directory does not exist, it is created.

  A canonical path is built using the name from an imdb and a network
  (if not None).
  """
  outdir = osp.abspath(osp.join(__C.ROOT_DIR, 'output', __C.EXP_DIR, imdb.name))
  if weights_filename is None:
    weights_filename = 'default'
  outdir = osp.join(outdir, weights_filename)
  if not os.path.exists(outdir):
    os.makedirs(outdir)
  return outdir 
Example 21
def get_output_tb_dir(imdb, weights_filename):
  """Return the directory where tensorflow summaries are placed.
  If the directory does not exist, it is created.

  A canonical path is built using the name from an imdb and a network
  (if not None).
  """
  outdir = osp.abspath(osp.join(__C.ROOT_DIR, 'tensorboard', __C.EXP_DIR, imdb.name))
  if weights_filename is None:
    weights_filename = 'default'
  outdir = osp.join(outdir, weights_filename)
  if not os.path.exists(outdir):
    os.makedirs(outdir)
  return outdir 
Example 22
def cache_path(self):
    cache_path = osp.abspath(osp.join(cfg.DATA_DIR, 'cache'))
    if not os.path.exists(cache_path):
      os.makedirs(cache_path)
    return cache_path 
Example 23
Project: BiblioPixelAnimations   Author: ManiacalLabs   File: setup.py    License: MIT License 5 votes vote down vote up
def _get_version():
    from os.path import abspath, dirname, join
    filename = join(dirname(abspath(__file__)), 'VERSION')
    print('Reading version from {}'.format(filename))
    version = open(filename).read().strip()
    print('Version: {}'.format(version))
    return version 
Example 24
Project: NiBetaSeries   Author: HBClab   File: create_long_description.py    License: MIT License 5 votes vote down vote up
def read(*names, **kwargs):
    return io.open(
        join(abspath(*names)),
        encoding=kwargs.get('encoding', 'utf8')
    ).read() 
Example 25
Project: python-rest-api   Author: messagebird   File: setup.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def get_description():
    working_directory = path.abspath(path.dirname(__file__))
    readme_path = path.join(working_directory, 'README.md')
    with open(readme_path, encoding='utf-8') as f:
        return (f.read(), 'text/markdown') 
Example 26
Project: delocate   Author: matthew-brett   File: test_tmpdirs.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_given_directory():
    # Test InGivenDirectory
    cwd = getcwd()
    with InGivenDirectory() as tmpdir:
        assert_equal(tmpdir, abspath(cwd))
        assert_equal(tmpdir, abspath(getcwd()))
    with InGivenDirectory(MY_DIR) as tmpdir:
        assert_equal(tmpdir, MY_DIR)
        assert_equal(realpath(MY_DIR), realpath(abspath(getcwd())))
    # We were deleting the Given directory!  Check not so now.
    assert_true(isfile(MY_PATH)) 
Example 27
Project: find_forks   Author: frost-nzcr4   File: run.py    License: MIT License 5 votes vote down vote up
def main():
    """Main function to run as shell script."""
    loader = unittest.TestLoader()
    suite = loader.discover(path.abspath(path.dirname(__file__)), pattern='test_*.py')
    runner = unittest.TextTestRunner(buffer=True)
    runner.run(suite) 
Example 28
Project: cascade-rcnn_Pytorch   Author: guoruoqian   File: config.py    License: MIT License 5 votes vote down vote up
def get_output_dir(imdb, weights_filename):
  """Return the directory where experimental artifacts are placed.
  If the directory does not exist, it is created.

  A canonical path is built using the name from an imdb and a network
  (if not None).
  """
  outdir = osp.abspath(osp.join(__C.ROOT_DIR, 'output', __C.EXP_DIR, imdb.name))
  if weights_filename is None:
    weights_filename = 'default'
  outdir = osp.join(outdir, weights_filename)
  if not os.path.exists(outdir):
    os.makedirs(outdir)
  return outdir 
Example 29
Project: cascade-rcnn_Pytorch   Author: guoruoqian   File: config.py    License: MIT License 5 votes vote down vote up
def get_output_tb_dir(imdb, weights_filename):
  """Return the directory where tensorflow summaries are placed.
  If the directory does not exist, it is created.

  A canonical path is built using the name from an imdb and a network
  (if not None).
  """
  outdir = osp.abspath(osp.join(__C.ROOT_DIR, 'tensorboard', __C.EXP_DIR, imdb.name))
  if weights_filename is None:
    weights_filename = 'default'
  outdir = osp.join(outdir, weights_filename)
  if not os.path.exists(outdir):
    os.makedirs(outdir)
  return outdir 
Example 30
Project: cascade-rcnn_Pytorch   Author: guoruoqian   File: imdb.py    License: MIT License 5 votes vote down vote up
def cache_path(self):
    cache_path = osp.abspath(osp.join(cfg.DATA_DIR, 'cache'))
    if not os.path.exists(cache_path):
      os.makedirs(cache_path)
    return cache_path