예제 #1
0
 def loopThroughAllTemplates(self):
     all_templates = self.allfiles("\\template\\")
     offsets = {}
     resizes = {}
     Templates = templates.Templates()
     print("Generating data....")
     for template in all_templates:
         template_name = Templates.getNameFromPath(template)
         offset, resize = self.findTemplateRegion(template)
         offsets[template_name] = offset
         resizes[template_name] = resize
     print("\n")
     print("OFFSET VALUES - GOES IN TEMPLATES FILE")
     print("-------------------------------------------------------")
     print("\n")
     print(offsets)
     print("\n")
     print("RESIZE VALUES - ALSO GOES IN TEMPLATES FILE ")
     print("----------------------------------------------------------")
     print("\n")
     print(resizes)
     print("\n")
     print("Script is pre-configured with several hundred templates.")
     print(
         "New template values for new templates must be added to the templates file before generation. Use the data above."
     )
     print("\n")
예제 #2
0
def make_output(outputfilename, templatedirs):
    for of in OUTPUT_FORMATS:
        extension = of['extension']
        if outputfilename.endswith('.' + extension):
            return OutputFormat(templates.Templates(templatedirs, extension),
                                of['quote'])
    raise Exception("Unsupported or unknown output format for %s." %
                    outputfilename)
예제 #3
0
    def __init__(self):
        super().__init__()
        self.ui = Ui_ProjTempl()
        self.ui.setupUi(self)

        self.templates = templates.Templates(warn_if_empty=False)
        self.setupConnects()

        self.show()
예제 #4
0
 def paste(self, template, source, template_name, source_name):
     Templates = templates.Templates()
     template_w, template_h = self.getImgSize(template)
     source_w, source_h = self.getImgSize(source)
     offset = Templates.getOffset(template_name)
     template.paste(source, offset)
     name = self.getName(self.OUT_DIRECTORY)
     template.save(name)
     print("Template: ", Templates.getNameFromPath(template_name),
           "Saved as: ", Templates.getNameFromPath(name))
예제 #5
0
 def make_meme(self):
     Templates = templates.Templates()
     template = self.getRandomTemplate()
     source = self.getRandomSource()
     template_name = template
     source_name = source
     template = self.readImg(template)
     source = self.readImg(source)
     source = Templates.getResizeShape(source, template, source_name,
                                       template_name)
     self.paste(template, source, template_name, source_name)
예제 #6
0
def ConsoleVersion(arg):

    local_json = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              templates.DEFAULT_JSON_NAME)
    tmpl = templates.Templates(data_path=local_json,
                               data_url=templates.DEFAULT_JSON_URL)

    if arg == "-h":
        tmpl.Help()
        return

    try:
        proj = sys.argv[2]
    except IndexError:
        print(
            "WARNING: No project template passed, will use default one instead."
        )
        proj = "default"

    tmpl.CopyTemplate(proj)