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


Python unipath.FSPath类代码示例

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


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

示例1: dict2dir

def dict2dir(dir, dic, mode="w"):
    dir = FSPath(dir)
    if not dir.exists():
        dir.mkdir()
    for filename, content in dic.iteritems():
        p = FSPath(dir, filename)
        if isinstance(content, dict):
            dict2dir(p, content)
            continue
        f = open(p, mode)
        f.write(content)
        f.close()
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:12,代码来源:tools.py

示例2: require_dir

def require_dir(config, key, create_if_missing=False):
    from unipath import FSPath as Path
    try:
        dir = config[key]
    except KeyError:
        msg = "config option '%s' missing"
        raise KeyError(msg % key)
    dir = Path(config[key])
    if not dir.exists():
        dir.mkdir(parents=True)
    if not dir.isdir():
        msg = ("directory '%s' is missing or not a directory "
               "(from config option '%s')")
        tup = dir, key
        raise OSError(msg % tup)
开发者ID:,项目名称:,代码行数:15,代码来源:

示例3: Path

from unipath import FSPath as Path
PROJECT_DIR = Path(__file__).absolute().ancestor(2)

######################################
# Main
######################################

DEBUG = True
ROOT_URLCONF = 'urls'
SITE_ID = 1

######################################
# Apps
######################################

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'south',
    'board',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
开发者ID:almet,项目名称:whiskerboard,代码行数:31,代码来源:base.py

示例4: Path

# Django settings for hweb project.
from unipath import FSPath as Path

DEBUG = True
TEMPLATE_DEBUG = DEBUG

# The full path to the hweb directory.
BASE = Path(__file__).absolute().ancestor(2)

ADMINS = (
    # ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': BASE.child('hweb').child('hweb.db'), # Or path to database file if using sqlite3.
        'USER': '', # Not used with sqlite3.
        'PASSWORD': '', # Not used with sqlite3.
        'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '', # Set to empty string for default. Not used with sqlite3.
    }
}

CACHES = {
    'default' : {
      'BACKEND' : 'django.core.cache.backends.memcached.MemcachedCache',
      'LOCATION' : '127.0.0.1:11211',
      #'BACKEND' : 'django.core.cache.backends.locmem.LocMemCache',
开发者ID:Zetten,项目名称:hweb,代码行数:31,代码来源:settings.py

示例5: Path

import platform
from unipath import FSPath as Path

BASE = Path(__file__).parent

DEBUG = TEMPLATE_DEBUG = platform.node() != 'jacobian.org'
MANAGERS = ADMINS = []

TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
USE_I18N = False
USE_L10N = False

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE.child('nn.db'),
    }
}
MIDDLEWARE_CLASSES = []

SITE_ID = 1
SECRET_KEY = 'LOCAL' if DEBUG else open('/home/web/sekrit.txt').read().strip()

ROOT_URLCONF = 'djangome.urls'
INSTALLED_APPS = ['djangome', 'gunicorn']
TEMPLATE_DIRS = [BASE.child('templates')]

REDIS = {
    'host': 'localhost',
    'port': 6379,
开发者ID:celeryclub,项目名称:djangome,代码行数:31,代码来源:settings.py

示例6: Path

# Django settings for okqa project.
import os
from unipath import FSPath as Path
import dj_database_url

PROJECT_DIR = Path(__file__).absolute().ancestor(3)

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = ()
MANAGERS = ADMINS
INTERNAL_IPS = ('127.0.0.1',)

# TODO: test if the next line is good for us
# SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
TIME_ZONE = 'Asia/Jerusalem'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
gettext = lambda s: s

LANGUAGES = (
    ('he', gettext('Hebrew')),
    ('en', gettext('English')),
    ('ar', gettext('Arabic')),
    ('ru', gettext('Russian')),
)

LANGUAGE_CODE = LANGUAGES[0][0]
开发者ID:david206,项目名称:ok-qa,代码行数:30,代码来源:base.py

示例7: env_or_default

import os
import dj_database_url

from unipath import FSPath as Path


def env_or_default(NAME, default):
    return os.environ.get(NAME, default)


PROJECT_ROOT = Path(__file__).ancestor(3)
PACKAGE_ROOT = PROJECT_ROOT.child('djangocon')

BASE_DIR = PACKAGE_ROOT

DEBUG = bool(int(os.environ.get("DEBUG", "1")))

DATABASES = {
    "default": dj_database_url.config(default="postgres://localhost/djangocon2016")
}

ALLOWED_HOSTS = [
    os.environ.get("GONDOR_INSTANCE_DOMAIN"),
    "2016.djangocon.us",
    "www.djangocon.us",
    "localhost',"
]

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
开发者ID:kennethlove,项目名称:2016.djangocon.us,代码行数:31,代码来源:base.py

示例8: Path

# Django settings for oakff_site project.
import os
from unipath import FSPath as Path

PROJECT_DIR = Path(__file__).absolute().ancestor(1)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'dummy.db',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
开发者ID:webmaven,项目名称:oaklandfoodfinder,代码行数:31,代码来源:settings.py

示例9: Path

# -*- coding: utf-8 -*-

import sys

from unipath import FSPath as Path

PROJECT_ROOT = Path(__file__).absolute().ancestor(2)
sys.path.insert(0, PROJECT_ROOT.child("apps"))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ("Your Name", "[email protected]"),
)

MANAGERS = ADMINS

TIME_ZONE = None
LANGUAGE_CODE = "en-us"
SITE_ID = 1
USE_I18N = True
USE_L10N = True

STATIC_ROOT = PROJECT_ROOT.child("static")
STATIC_URL = "/static/"
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)
开发者ID:superbobry,项目名称:grepo,代码行数:31,代码来源:base.py

示例10: Path

import sys

from unipath import FSPath as Path

PROJECT_ROOT = Path(__file__).absolute().ancestor(2)
sys.path.insert(0, PROJECT_ROOT.child("apps"))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'dev.db', # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '', # Set to empty string for default.
    }
}

# Hosts/domain names that are valid for this site; required if DEBUG is False
开发者ID:katyasosa,项目名称:is_project,代码行数:31,代码来源:settings.py

示例11: handle_noargs

 def handle_noargs(self, **kwargs):
     try:
         verbose = int(kwargs['verbosity']) > 0
     except (KeyError, TypeError, ValueError):
         verbose = True
     
     for release in DocumentRelease.objects.all():
         if verbose:
             print "Updating %s..." % release
             
         destdir = Path(settings.DOCS_BUILD_ROOT).child(release.lang, release.version)
         if not destdir.exists():
             destdir.mkdir(parents=True)
         
         # Make an SCM checkout/update into the destination directory.
         # Do this dynamically in case we add other SCM later.
         getattr(self, 'update_%s' % release.scm)(release.scm_url, destdir)
         
         # Make the directory for the JSON files - sphinx-build doesn't
         # do it for us, apparently.
         json_build_dir = destdir.child('_build', 'json')
         if not json_build_dir.exists():
             json_build_dir.mkdir(parents=True)
         
         # "Shell out" (not exactly, but basically) to sphinx-build.
         sphinx.cmdline.main(['sphinx-build',
             '-b', 'json',      # Use the JSON builder
             '-q',              # Be vewy qwiet
             destdir,           # Source file directory
             json_build_dir,    # Destination directory
         ])
开发者ID:MyaThandarKyaw,项目名称:djangoproject.com,代码行数:31,代码来源:update_docs.py

示例12: document

def document(request, lang, version, url):
    if lang != 'en' or version != 'dev': raise Http404()

    docroot = Path(settings.DOCS_PICKLE_ROOT)

    # First look for <bits>/index.fpickle, then for <bits>.fpickle
    bits = url.strip('/').split('/') + ['index.fpickle']
    doc = docroot.child(*bits)
    if not doc.exists():
        bits = bits[:-2] + ['%s.fpickle' % bits[-2]]
        doc = docroot.child(*bits)
        if not doc.exists():
            raise Http404("'%s' does not exist" % doc)

    bits[-1] = bits[-1].replace('.fpickle', '')
    template_names = [
        'docs/%s.html' % '-'.join([b for b in bits if b]), 
        'docs/doc.html'
    ]
    return render_to_response(template_names, RequestContext(request, {
        'doc': pickle.load(open(doc, 'rb')),
        'env': pickle.load(open(docroot.child('globalcontext.pickle'), 'rb')),
        'update_date': datetime.datetime.fromtimestamp(docroot.child('last_build').mtime()),
        'home': urlresolvers.reverse('document-index', kwargs={'lang':lang, 'version':version}),
        'search': urlresolvers.reverse('document-search', kwargs={'lang':lang, 'version':version}),
        'redirect_from': request.GET.get('from', None),
    }))
开发者ID:BillTheBest,项目名称:lucid-website,代码行数:27,代码来源:views.py

示例13: handle_noargs

 def handle_noargs(self, **options):
     project_dir = Path(__file__).absolute().ancestor(4)
     data_file = project_dir.child("static", "js", "station_polys.json")
     with open(data_file, "r") as f:
         data = json.loads(f.read())
         for station_id, coords in data.items():
             station = Station.objects.get(id=station_id)
             station.polygon = coords
             station.save()
开发者ID:idan,项目名称:telostats,代码行数:9,代码来源:import_station_json.py

示例14: run_benchmarks

def run_benchmarks(control, benchmark_dir, benchmarks, trials, record_dir=None, profile_dir=None):
    if benchmarks:
        print "Running benchmarks: %s" % " ".join(benchmarks)
    else:
        print "Running all benchmarks"

    if record_dir:
        record_dir = Path(record_dir).expand().absolute()
        if not record_dir.exists():
            raise ValueError('Recording directory "%s" does not exist' % record_dir)
        print "Recording data to '%s'" % record_dir

    control_label = get_django_version(control, vcs=None)
    branch_info =  ""
    print "Benchmarking: Django %s (in %s%s)" % (control_label, branch_info, control)
    print "    Control: %s" % cpython
    print "    Experiment: %s" % pypy
    print
    
    control_env = {'PYTHONPATH': '.:%s:%s' % (Path(control).absolute(), Path(benchmark_dir))}
    
    for benchmark in discover_benchmarks(benchmark_dir):
        if not benchmarks or benchmark.name in benchmarks:
            print "Running '%s' benchmark ..." % benchmark.name
            settings_mod = '%s.settings' % benchmark.name
            control_env['DJANGO_SETTINGS_MODULE'] = settings_mod
            experiment_env = control_env.copy()
            if profile_dir is not None:
                control_env['DJANGOBENCH_PROFILE_FILE'] = Path(profile_dir, "cpython-%s" % benchmark.name)
                experiment_env['DJANGOBENCH_PROFILE_FILE'] = Path(profile_dir, "pypy-%s" % benchmark.name)
            try:
                control_data = run_benchmark(benchmark, trials, control_env, cpython)
                experiment_data = run_benchmark(benchmark, trials, experiment_env, pypy)
            except SkipBenchmark, reason:
                print "Skipped: %s\n" % reason
                continue

            options = argparse.Namespace(
                track_memory = False,
                diff_instrumentation = False,
                benchmark_name = benchmark.name,
                disable_timelines = True,
            )
            result = perf.CompareBenchmarkData(control_data, experiment_data, options)
            if record_dir:
                record_benchmark_results(
                    dest = record_dir.child('%s.json' % benchmark.name),
                    name = benchmark.name,
                    result = result,
                    control = 'cpython',
                    experiment = 'pypy',
                    control_data = control_data,
                    experiment_data = experiment_data,
                )
            print format_benchmark_result(result, len(control_data.runtimes))
            print
开发者ID:fennb,项目名称:djangobench,代码行数:56,代码来源:main.py

示例15: do_build

    def do_build(self, arguments):
        # If no course arguments are given, build all the courses.
        if arguments['<course>']:
            try:
                courses = [self.library.courses[c] for c in arguments['<course>']]
            except KeyError:
                raise CLIError("No such course:", c)
        else:
            courses = self.library.courses.values()

        for course in courses:
            self.out.write(u'Building %s\n' % course.title)

            # Make the dest directory.
            dest = self.library.build_path.child(course.slug)
            if dest.exists():
                dest.rmtree()
            dest.mkdir(parents=True)

            # Create the sphinx support directories (_static, _templates) by
            # merging directories from the internal chucks-support directory
            # and from the library's theme if it exists. This has to happen
            # before building the handounts and Sphinx docs because both those
            # steps uses these components.
            for subdir in ('_static', '_templates'):
                chucksdir = self.support_path.child(subdir)
                themedir = self.library.theme_path.child(subdir)
                sources = [d for d in (chucksdir, themedir) if d.exists()]
                if not dest.child(subdir).exists():
                    dest.child(subdir).mkdir()
                fileutils.merge_trees(sources, dest.child(subdir))

            # Write out an auth.json for the deployment step. This should
            # probably actually become part of the deployment step at some point.
            if hasattr(course, 'auth'):
                json.dump(course.auth, open(dest.child('auth.json'), 'w'))

            # Handouts have to go first: Sphinx links to the handouts.
            self._build_handouts(course)
            self._build_sphinx(course)

            # Copy over any extra files to be downloaded. FIXME: This is a nasty
            # hack. Inject these into toc.html as download links?
            for fname in getattr(course, 'downloads', []):
                p = Path(fname)
                if p.isabsolute():
                    src = p
                else:
                    src = self.library.path.child(*p.components())
                shutil.copy(src, dest.child('html'))
开发者ID:jacobian,项目名称:chucks,代码行数:50,代码来源:cli.py


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