本文整理汇总了Python中unipath.Path.cwd方法的典型用法代码示例。如果您正苦于以下问题:Python Path.cwd方法的具体用法?Python Path.cwd怎么用?Python Path.cwd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unipath.Path
的用法示例。
在下文中一共展示了Path.cwd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import cwd [as 别名]
def create(dataset, work_dir):
# Find all the pages in the dataset
img_dir = Path(Path.cwd().ancestor(1), 'data/hwr_data/pages', dataset)
ann_dir = Path(Path.cwd().ancestor(1), 'data/charannotations')
images = img_dir.listdir('*.jpg')
annotations = ann_dir.listdir(dataset + '*.words')
files = merge(images, annotations)
# Create character segmentations
stats = {}
for f in files:
# Preprocess
logging.info("Preprocessing %s", str(f[0]))
pagesPathFolder = Path(work_dir, 'pages')
pagesPathFolder.mkdir()
pagePath = Path(pagesPathFolder, f[0].stem + '.ppm')
img = cv2.imread(f[0], cv2.IMREAD_GRAYSCALE)
img = preprocess(img)
cv2.imwrite(pagePath, img)
# Segment
segmentPathFolder = Path(work_dir, 'segments')
segmentPathFolder.mkdir()
e = ET.parse(f[1]).getroot()
logging.info("Segmenting %s", str(f[0]))
segment(img, e, segmentPathFolder, stats)
print_statistics(stats, dataset)
示例2: fixtures
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import cwd [as 别名]
def fixtures(module, yaml_file):
yaml_file = Path.cwd().child(app_name, module, 'tests', 'fixtures', '%s.yml' % yaml_file)
with open(yaml_file) as yaml_file:
fixtures = yaml.load(yaml_file.read())
def load_fixture(fixture_name):
if fixture_name in fixtures:
return fixtures[fixture_name]
else:
raise LookupError('%s doesnt exists in this fixture file' % fixture_name)
return load_fixture
示例3: make_ota_package
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import cwd [as 别名]
def make_ota_package(self, *, kbuild_image_dir: Optional[Path]="",
output_dir: Path, source_dir: Path=Path.cwd()) -> Path:
"""Create an Over the Air (OTA) package that can be installed via recovery.
Keyword Args:
output_dir: Where the otapackage will be stored
source_dir: The directory to be zipped (default cwd)
kbuild_image_dir: Optional path to to copy kbuild image into; relative to source_dir
Returns:
the path to the zip file created.
"""
if kbuild_image_dir:
shutil.copy(self.kbuild_image.as_posix(), (source_dir / kbuild_image_dir).as_posix())
archive_path = output_dir / self.custom_release.lower()
archive_name = archive_path.as_posix()
return Path(shutil.make_archive(archive_name, 'zip', source_dir))
示例4: create_own_lexicon
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import cwd [as 别名]
def create_own_lexicon():
lexicon = {}
for dataset in ['KNMP', 'Stanford']:
# Find all the annotated pages in the dataset
ann_dir = Path(Path.cwd().ancestor(1), 'data/hwr_data/words/' + dataset)
annotations = ann_dir.listdir( '*.words')
for f in annotations:
# Segment
annotation = ET.parse(f).getroot()
for word in annotation.iter('Word'):
text = word.get('text')
# Add word to lexicon
if lexicon.has_key(text):
lexicon[text] += 1
else :
lexicon[text] = 1
return lexicon
示例5: ValueError
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import cwd [as 别名]
else:
raise ValueError("invalid default answer: '%s'" % default)
while True:
sys.stdout.write(question + prompt)
choice = raw_input().lower()
if default is not None and choice == "":
return valid[default]
elif choice in valid:
return valid[choice]
else:
sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n")
# mypath = '/home/gavin/Code/destapi/djangomedia/images/'
mypath = Path.cwd().ancestor(1) + "/djangomedia/images/"
def count_files():
global f, onlyfiles
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
count_files()
con = None
image_list = []
queries = [
("SELECT img_url FROM core_page WHERE LENGTH (img_url)>1", "Page"),
("SELECT img_url2 FROM core_sector WHERE LENGTH (img_url2)>1", "Sector"),
示例6:
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import cwd [as 别名]
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'eyw5spd)&u1gkzwxjarmul#&aj3axf6=emkc204e*6-di_a&8r'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
from unipath import Path
RUTA_PROYECTO = Path.cwd()
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'cliente',