Esempio n. 1
0
def parse_and_store__component_display_name():
    for dir_path in software_directory_paths:
        language_path = SOFTWARES_PATH + dir_path + COMPONENTS_LANG_PATH
        file_names = []
        for (dirpath, dirnames, filenames) in walk(language_path):
            file_names.extend(filenames)
            break
        for file_name in file_names:
            if (not file_name.endswith('_en_US.properties')) and (
                    not file_name.endswith('locale.properties')):
                continue
            configs = Properties()
            path = SOFTWARES_PATH + dir_path + COMPONENTS_LANG_PATH + file_name
            with open(path, 'rb') as read_prop:
                configs.load(read_prop)
            prop_view = configs.items()
            #print(type(prop_view))
            for item in prop_view:
                #print(item)
                if len(item[0].split('.')) > 1 and item[0].split(
                        '.')[1] == 'displayName' and item[0].split(
                            '.')[0] in component_object:
                    display_name = configs.get(item[0]).data
                    component_id = item[0].split('.')[0]
                    component_object[component_id].set_component_display_name(
                        display_name)
def propsTranslator(separator, inputfile, languages):
    global CURR_LANGUAGE
    for curr in languages:
        CURR_LANGUAGE = curr
        props = Properties()
        with open(inputfile, 'rb') as f:
            props.load(f, encoding='utf-8')
            newProps = Properties()
            for k, v in props.items():
                print("translate: {} to language: {}".format(
                    v.data, CURR_LANGUAGE))
                response = client.translate_text(
                    parent=GOOGLE_PARENT_PROJECT,
                    mime_type="text/plain",
                    target_language_code=CURR_LANGUAGE,
                    contents=[v.data])
                trans = response.translations
                print("result: {} \n".format(trans[0].translated_text))
                newProps[k] = trans[0].translated_text

            base = os.path.basename(inputfile)
            filename = os.path.splitext(base)[0]
            with open(filename + separator + CURR_LANGUAGE + '.properties',
                      'wb') as newF:
                newProps.store(newF, encoding='utf-8')
Esempio n. 3
0
def parse_and_store__artifact_display_name():
    for dir_path in software_directory_paths:
        language_path = SOFTWARES_PATH + dir_path + ARTIFACTS_LANG_PATH
        file_names = []
        for (dirpath, dirnames, filenames) in walk(language_path):
            file_names.extend(filenames)
            break
        for file_name in file_names:
            if (not file_name.endswith('_en_US.properties')) and (
                    not file_name.endswith('locale.properties')):
                continue

            configs = Properties()
            path = SOFTWARES_PATH + dir_path + ARTIFACTS_LANG_PATH + file_name
            # print("Artifact lang :path",path)
            with open(path, 'rb') as read_prop:
                configs.load(read_prop)
            prop_view = configs.items()
            for item in prop_view:
                if len(item[0].split('.')) > 1 and item[0].split(
                        '.')[1] == 'displayName':
                    display_name = configs.get(item[0]).data
                    artifact_id = item[0].split('.')[0].lower()
                    artifact_object[artifact_id] = Artifact(
                        artifact_id, display_name)
def get_value_from_properties_file_by_key(attr_type):
    configs = Properties()
    with open('SystemProperties.properties', 'rb') as read_prop:
        configs.load(read_prop)
        prop_view = configs.items()
        # print(type(prop_view))
        for item in prop_view:
            # print(item)
            if item[0] == attr_type:
                return item[1][0]
Esempio n. 5
0
def _readproperties(filepath):
    configs = Properties()
    with open(filepath, 'rb') as config_file:
        configs.load(config_file)
    items_pro = configs.items()
    # This will create empty dictionary object
    prop_dict = {}
    for item in items_pro:
        prop_dict[item[0]] = item[1].data
    # print(item[0],"=",item[1].data)
    return prop_dict
Esempio n. 6
0
def get_configs(file_name):
    configs = Properties()
    with open(file_name, 'rb') as config_file:
        configs.load(config_file)
        config_file.close()
    items_view = configs.items()
    configs_dict = {}

    for item in items_view:
        configs_dict[item[0]] = item[1].data
    return configs_dict
Esempio n. 7
0
def read_config_file(file_path):
    configs = Properties()

    with open(file_path, 'rb') as config_file:
        configs.load(config_file)

    items_view = configs.items()
    db_configs_dict = {}

    for item in items_view:
        db_configs_dict[item[0]] = item[1].data
    return db_configs_dict
Esempio n. 8
0
def load_properties(args):
    props = Properties()
    with open(args.filepath, 'rb') as prop_file:
        props.load(prop_file, 'utf-8')

    # log it clean
    dashes = 10 * '-'
    logger.info(f'{dashes}Properties loaded successfully.{dashes}')
    for k, v in props.items():
        logger.info(f'{k} = {v}')
    logger.info(dashes * 5)

    return props
Esempio n. 9
0
    def configReader(self, value):
        self.value = value
        #Opening Config File
        config = Properties()
        with open(
                "C:/Users/vignesh/PycharmProjects/PythonTutorials/AugBatch/POMDemo/Config/config.properties",
                'rb') as config_file:
            config.load(config_file)

        for items in config.items():
            if 'url' in self.value:
                val = items[1].data
                break
        return val
Esempio n. 10
0
def setup():
    global file_errors_records, file_exported_datasets_list, headers_file, templateLoader, templateEnv, headers, \
        dataset_json_template, file_json_template, configs_dict
    timestamp_str = '_' + datetime.now().strftime("%Y%m%d_%H%M%S")
    file_errors_records = open(config.FILE_CSV_ERRORS_RECORDS + timestamp_str + '.csv', 'a')
    file_exported_datasets_list = open(config.FILE_EXPORTED_RECORDS + timestamp_str + '.txt', 'a')
    headers = {'X-Dataverse-key': config.DATAVERSE_API_TOKEN}
    headers_file = {
        'X-Dataverse-key': config.DATAVERSE_API_TOKEN,
    }
    templateLoader = jinja2.FileSystemLoader(searchpath="./resources/templates")
    templateEnv = jinja2.Environment(loader=templateLoader)
    print(config.DATASET_JSON_TEMPLATE)
    dataset_json_template = templateEnv.get_template(config.DATASET_JSON_TEMPLATE)
    file_json_template = templateEnv.get_template(config.FILE_JSON_TEMPLATE)
    configs = Properties()
    with open(config.JINJA_CSV_MAPPING_FILE, 'rb') as read_prop:
        configs.load(read_prop)
    items_view = configs.items()
    configs_dict = {}
    for item in items_view:
        configs_dict[item[0]] = item[1].data
    print(configs_dict)
Esempio n. 11
0
def _test_serialize(*data):
	for items, s in data:
		d = OrderedDict(items)
		props = Properties(d)
		assert list(props.items()) == items
Esempio n. 12
0
def _test_deserialize(*data):
    for s, items in data:
        props = Properties()
        props.load(StringIO(s))
        assert list(props.items()) == items
Esempio n. 13
0
def properties2json(p: Properties):
    return OrderedDict(sorted(p.items(), key=lambda x: x[0]))
Esempio n. 14
0
def properties2json_v2(p: Properties, spilt_char: str = "."):
    raw_dict = {}
    for k, v in p.items():
        update_dict(raw_dict, k.split(spilt_char), v)
    return raw_dict
Esempio n. 15
0
def _test_deserialize(*data):
	for s, items in data:
		props = Properties()
		props.load(StringIO(s))
		assert list(props.items()) == items
Esempio n. 16
0
from jproperties import Properties

config = Properties()
file_obj = codecs.open(
    'C:\\Users\\Vignesh\\Cucumber_AutomationBytes\\Booking\\Config.Properties',
    'rb')
with open(
        'C:\\Users\\Vignesh\\Cucumber_AutomationBytes\\Booking\\Config.Properties',
        'rb') as config_file:
    config.load(config_file)
print(config.get("user"))

items_view = config.items()
for item in items_view:
    print(item[0], '=', item[1].data)
Esempio n. 17
0
def _test_serialize(*data):
    for items, s in data:
        d = OrderedDict(items)
        props = Properties(d)
        assert list(props.items()) == items