def get_upload_path(translation_project, relative_root_dir, local_filename): """gets the path of a translation file being uploaded securely, creating directories as neccessary""" dir_path = os.path.join(translation_project.real_path, unix_to_host_path(relative_root_dir)) return relative_real_path(os.path.join(dir_path, local_filename))
def add_files(translation_project, ignored_files, ext, real_dir, db_dir, file_filter=lambda _x: True): files, dirs = split_files_and_dirs(ignored_files, ext, real_dir, file_filter) existing_stores = dict( (store.name, store) for store in db_dir.child_stores.exclude(file='').iterator()) existing_dirs = dict( (dir.name, dir) for dir in db_dir.child_dirs.iterator()) add_items( files, existing_stores, lambda name: Store(file=relative_real_path(os.path.join( real_dir, name)), parent=db_dir, name=name, translation_project=translation_project)) db_subdirs = add_items(dirs, existing_dirs, lambda name: Directory(name=name, parent=db_dir)) for db_subdir in db_subdirs: fs_subdir = os.path.join(real_dir, db_subdir.name) add_files(translation_project, ignored_files, ext, fs_subdir, db_subdir, file_filter)
def get_upload_path(translation_project, relative_root_dir, local_filename): """gets the path of a translation file being uploaded securely, creating directories as necessary""" dir_path = os.path.join(translation_project.real_path, unix_to_host_path(relative_root_dir)) return relative_real_path(os.path.join(dir_path, local_filename))
def set_download_file(self, path_obj, filepath): """Set file for download """ filename = relative_real_path(filepath) export_path = os.path.join('POOTLE_EXPORT', filename) abs_export_path = absolute_real_path(export_path) try: ensure_target_dir_exists(abs_export_path) shutil.copyfile(filepath, abs_export_path) except (IOError, OSError, shutil.Error), e: msg = (_("Failed to copy download file to export directory %s") % abs_export_path) logger.exception('%s', msg) return ''.join([msg, ": ", str(e)])
def set_download_file(self, path_obj, filepath): """Set file for download """ filename = relative_real_path(filepath) export_path = os.path.join('POOTLE_EXPORT', filename) abs_export_path = absolute_real_path(export_path) try: ensure_target_dir_exists(abs_export_path) shutil.copyfile(filepath, abs_export_path) except (IOError, OSError, shutil.Error), e: msg = (_("Failed to copy download file to export directory %s") % abs_export_path) logger.exception('%s', msg) return ''.join([msg, ": ", str(e)])
def add_files(translation_project, ignored_files, ext, real_dir, db_dir, file_filter=lambda _x: True): files, dirs = split_files_and_dirs(ignored_files, ext, real_dir, file_filter) existing_stores = dict((store.name, store) for store in db_dir.child_stores.exclude(file='').iterator()) existing_dirs = dict((dir.name, dir) for dir in db_dir.child_dirs.iterator()) add_items(files, existing_stores, lambda name: Store(file = relative_real_path(os.path.join(real_dir, name)), parent = db_dir, name = name, translation_project = translation_project)) db_subdirs = add_items(dirs, existing_dirs, lambda name: Directory(name=name, parent=db_dir)) for db_subdir in db_subdirs: fs_subdir = os.path.join(real_dir, db_subdir.name) add_files(translation_project, ignored_files, ext, fs_subdir, db_subdir, file_filter)
def set_download_file(self, path_obj, filepath): """Set file for download """ filename = relative_real_path(filepath) export_path = os.path.join('POOTLE_EXPORT', filename) abs_export_path = absolute_real_path(export_path) try: ensure_target_dir_exists(abs_export_path) shutil.copyfile(filepath, abs_export_path) except (IOError, OSError, shutil.Error) as e: msg = (_("Failed to copy download file to export directory %s") % abs_export_path) logger.exception('%s', msg) return ''.join([msg, ": ", str(e)]) cache.set(self._cache_key(path_obj), path_obj.get_mtime(), settings.OBJECT_CACHE_TIMEOUT) self._dl_path[path_obj.pootle_path] = export_path return ''
def set_download_file(self, path_obj, filepath): """Set file for download """ filename = relative_real_path(filepath) export_path = os.path.join('POOTLE_EXPORT', filename) abs_export_path = absolute_real_path(export_path) try: ensure_target_dir_exists(abs_export_path) shutil.copyfile(filepath, abs_export_path) except (IOError, OSError, shutil.Error) as e: msg = (_("Failed to copy download file to export directory %s") % abs_export_path) logger.exception('%s', msg) return ''.join([msg, ": ", str(e)]) cache.set(self._cache_key(path_obj), path_obj.get_mtime(), settings.OBJECT_CACHE_TIMEOUT) self._dl_path[path_obj.pootle_path] = export_path return ''
def to_podir_path(path): path = relative_real_path(path) return os.path.join(settings.POOTLE_TRANSLATION_DIRECTORY, path)
def to_podir_path(path): path = relative_real_path(path) return os.path.join(settings.POOTLE_TRANSLATION_DIRECTORY, path)
def abs_real_path(self, value): if value is not None: self.real_path = relative_real_path(value) else: self.real_path = None
def to_podir_path(path): path = relative_real_path(path) return os.path.join(settings.PODIRECTORY, path)
def to_podir_path(path): path = relative_real_path(path) return os.path.join(settings.PODIRECTORY, path)
def to_vcs_path(path): # FIXME: this is ignoring symlinks! path = relative_real_path(path) return os.path.join(settings.VCS_DIRECTORY, path)
def _set_abs_real_path(self, value): self.real_path = relative_real_path(value)
def abs_real_path(self, value): if value is not None: self.real_path = relative_real_path(value) else: self.real_path = None
def abs_real_path(self, value): self.real_path = relative_real_path(value)
def to_vcs_path(path): path = relative_real_path(path) return os.path.join(settings.VCS_DIRECTORY, path)