Example #1
0
 def _new_resource(self, base_resource, node, page_number):
     """
     Create a new resource as a copy of a base_resource, with a page of
     resources associated with it.
     """
     res = Resource(base_resource.source_file, node)
     path = self._relative_url(base_resource.relative_path,
                             page_number,
                             base_resource.source_file.name_without_extension,
                             base_resource.source_file.extension)
     res.set_relative_deploy_path(path)
     return res
Example #2
0
 def _new_resource(self, base_resource, node, page_number):
     """
     Create a new resource as a copy of a base_resource, with a page of
     resources associated with it.
     """
     res = Resource(base_resource.source_file, node)
     path = self._relative_url(
         base_resource.relative_path, page_number,
         base_resource.source_file.name_without_extension,
         base_resource.source_file.extension)
     res.set_relative_deploy_path(path)
     return res
Example #3
0
def new_dark_resource(node, base_resource):
    path = base_resource.get_relative_deploy_path()
    new_path = patch_filename(path)
    if new_path is None:
        return None

    res = Resource(base_resource.source_file, node)
    res.set_relative_deploy_path(new_path)

    try:
        res.meta = copy.deepcopy(base_resource.meta)
        res.meta.dark = True
    except Exception:
        print "Unexpected error:", sys.exc_info()[0]
        return None

    return res
Example #4
0
def new_i18n_resource(node, base_resource, language):
    res = Resource(base_resource.source_file, node)
    path = get_i18n_path(res.get_relative_deploy_path(), language)
    res.set_relative_deploy_path(path)

    # set some hints for further processing in later steps
    res.meta = base_resource.meta
    res.auto_generated_language = True
    res.content_language = get_lang(base_resource) or default_language
    res.language = language

    return res