def add(options): if len(argv) != 2: templatetools.print_usage(options['indicator']) sys.exit(4) abs_template_path = templatetools.get_template_path_from_project() abs_command_path = os.path.abspath(os.path.dirname(sys.argv[0])) if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] template_python_dir = os.path.join(abs_template_path, 'store', 'python') # take files from command directory if don't exist python_file = os.path.join(template_python_dir, 'indicator.py') python_name = templatetools.python_name(project_name) target_python_dir = python_name project_sentence_name, project_camel_case_name = \ templatetools.conventional_names(project_name) substitutions = (("project_name", project_name), ("python_name", python_name)) templatetools.file_from_template(template_python_dir, "indicator.py", target_python_dir, substitutions)
def add(options): if len(argv) != 2: templatetools.print_usage(options['indicator']) sys.exit(4) abs_template_path = templatetools.get_template_path_from_project() abs_command_path = os.path.abspath(os.path.dirname(sys.argv[0])) if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] template_python_dir = os.path.join(abs_template_path, 'store', 'python') # take files from command directory if don't exist python_file = os.path.join(template_python_dir, 'indicator.py') python_name = templatetools.python_name(project_name) target_python_dir = python_name project_sentence_name, project_camel_case_name = \ templatetools.conventional_names(project_name) substitutions = (("project_name",project_name), ( "python_name",python_name)) templatetools.file_from_template(template_python_dir, "indicator.py", target_python_dir, substitutions)
All the help pages are loaded into your editor as well as the python files. """) def add(options): if len(argv) != 3: templatetools.print_usage(options['help-topic']) sys.exit(4) try: topic_name = templatetools.quickly_name(argv[2]) except templatetools.bad_project_name, e: print(e) sys.exit(1) abs_template_path = templatetools.get_template_path_from_project() abs_command_path = os.path.abspath(os.path.dirname(sys.argv[0])) if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] template_help_dir = os.path.join(abs_template_path, 'store', 'data', 'mallard') # take files from command directory if don't exist help_page = os.path.join(template_help_dir, 't_o_p_i_c.page') if not os.path.isfile(help_page): template_help_dir = os.path.join(abs_command_path, 'store', 'data', 'mallard')
swf = os.path.realpath(sys.argv[2]) if not os.path.exists(swf): print _("""Flash SWF file '%s' not found.\nUsage is: quickly create ubuntu-flash-game project_name myflashgame.swf""" % swf) sys.exit(6) # check that project name follow quickly rules and reformat it. try: project_name = templatetools.quickly_name(project_name) except templatetools.bad_project_name, e: print(e) sys.exit(1) os.chdir(project_name) # get origin path pathname = templatetools.get_template_path_from_project() abs_path_project_root = os.path.join(pathname, 'project_root') python_name = templatetools.python_name(project_name) sentence_name, camel_case_name = templatetools.conventional_names(project_name) # Calculate the SWF's dimensions try: width, height = SWF.dimensions(swf) except SWF.SWFNotASWF: print "File '%s' does not seem to be a SWF. Terminating." sys.exit(7) except SWF.SWFNoDimensions: print "(Could not read size from SWF file; defaulting to 640x480. You should edit bin/%s with the correct size.)" % project_name width, height = (640, 480)
3. Run the dialog and hide the dialog result = dialog.run() dialog.hide()""") def add(options): if len(argv) != 3: templatetools.print_usage(options['dialog']) sys.exit(4) try: dialog_name = templatetools.quickly_name(argv[2]) except templatetools.bad_project_name, e: print(e) sys.exit(1) abs_template_path = templatetools.get_template_path_from_project() abs_command_path = os.path.abspath(os.path.dirname(sys.argv[0])) if not configurationhandler.project_config: configurationhandler.loadConfig() project_name = configurationhandler.project_config['project'] template_ui_dir = os.path.join(abs_template_path, 'store', 'data', 'ui') template_python_dir = os.path.join(abs_template_path, 'store', 'python') # take files from command directory if don't exist origin_ui_file_list = [os.path.join(template_ui_dir, 'dialog_camel_case_nameDialog.ui'), os.path.join(template_ui_dir, 'dialog_python_name_dialog.xml')] python_file = os.path.join(template_ui_dir, 'dialog_camel_case_nameDialog.py')
def get_addable(): parent_path = os.path.dirname(__file__) template_path = templatetools.get_template_path_from_project() get_addable_from_path(os.path.join(parent_path, "store")) get_addable_from_path(os.path.join(template_path, "store"))
def _create_project(names, type_names, project_type="project_root"): project_root_prefix = "%s_" % project_type include_guard_names = [] include_guard_names.append(names.all_caps_name) include_guard_names.append(names.all_caps_name) include_guard_names.append("H") include_guard = "_".join(include_guard_names) open_namespace = "namespace %s\n{" % names.project_name close_namespace = "} /* namespace %s */" % names.project_name author_name = "Your Name" full_copyright_line = "YYYY <Your Name> <Your E-mail>" bzr_whoami = subprocess.Popen(["bzr","whoami"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) bzr_output, bzr_errors= bzr_whoami.communicate() if bzr_output.find('.', bzr_output.find('@')) != -1: author_name = bzr_output.strip() full_copyright_line = "%s %s" % (datetime.datetime.now().year, author_name) substitutions = ( ("type_camel_case_name",type_names.camel_case_name), ("type_sentence_name",type_names.sentence_name), ("plugin_type",type_names.project_name), ("include_guard", include_guard), ("all_caps_project_name", names.all_caps_name), ("project_name",names.project_name), ("camel_case_name",names.camel_case_name), ("sentence_name",names.sentence_name), ("all_caps_name",names.all_caps_name), ("class_name",names.project_name), ("open_namespace",open_namespace), ("close_namespace",close_namespace), ("author_name",author_name), ("full_copyright_line",full_copyright_line), ) # get origin path pathname = templatetools.get_template_path_from_project() for abs_path_project_root in [os.path.join(pathname, f) for f in (project_type, '%s%s' % (project_root_prefix, type_names.project_name))]: if os.path.isdir(abs_path_project_root): for root, dirs, files in os.walk(abs_path_project_root): try: relative_dir = root.split('%s/' % abs_path_project_root)[1] except: relative_dir = "" # python dir should be replace by python (project "pythonified" name) if relative_dir.startswith('project_name'): relative_dir = relative_dir.replace('project_name', names.project_name) for directory in dirs: if directory == 'project_name': directory = names.project_name try: os.mkdir(os.path.join(relative_dir, directory)) except OSError: # We don't care - we may be merging dirs pass for filename in files: quicklyutils.file_from_template(root, filename, relative_dir, substitutions)
def get_addable(): parent_path = os.path.dirname(__file__) template_path = templatetools.get_template_path_from_project() get_addable_from_path(os.path.join(parent_path, 'store')) get_addable_from_path(os.path.join(template_path, 'store'))
path_and_project = sys.argv[1].split('/') project_name = path_and_project[-1] try: project_name = templatetools.quickly_name(project_name) except: # user friendly message already caught in pre_create sys.exit(1) if len(path_and_project) > 1: os.chdir(str(os.path.sep).join(path_and_project[0:-1])) os.chdir(project_name) # get origin path pathname = templatetools.get_template_path_from_project() abs_path_project_root = os.path.join(pathname, 'project_root') python_name = templatetools.python_name(project_name) sentence_name, camel_case_name = templatetools.conventional_names(project_name) substitutions = (("project_name",project_name), ("camel_case_name",camel_case_name), ("python_name",python_name), ("sentence_name",sentence_name),) for root, dirs, files in os.walk(abs_path_project_root): try: relative_dir = root.split('project_root/')[1] except: relative_dir = ""