rewited funcs
This commit is contained in:
55
main.py
55
main.py
@@ -1,31 +1,24 @@
|
||||
#!/usr/bin/pyhton3
|
||||
import os
|
||||
import re
|
||||
from fnmatch import fnmatch
|
||||
|
||||
_path = r'C:/Users/riksl/PycharmProjects/weapon-project-extended/data/scripts/'
|
||||
|
||||
name = "weapongenerator.lua"
|
||||
from lib.translate import translate
|
||||
|
||||
|
||||
def _lister(_path) -> list:
|
||||
_list: list = []
|
||||
try:
|
||||
pattern = "*.lua"
|
||||
def scan_files(path) -> list:
|
||||
"""
|
||||
Scans dirs and subdirs in PATH to gind *.lua files
|
||||
:param path: set path to scan
|
||||
:return: list of files in dir and subdir
|
||||
"""
|
||||
list_files = []
|
||||
for root, dirs, files in os.walk(path):
|
||||
for file in files:
|
||||
if '.lua' in file: list_files.append(f'{root}/{file}')
|
||||
|
||||
for path, subdirs, files in os.scandir(_path):
|
||||
for name in files:
|
||||
if fnmatch(name, pattern):
|
||||
print(os.path.join(path, name))
|
||||
_list.extend(f"{path}/{name}")
|
||||
break
|
||||
return sorted(_list)
|
||||
except TypeError:
|
||||
pass
|
||||
return list_files
|
||||
|
||||
|
||||
print(_path)
|
||||
print(_lister(_path))
|
||||
# name = "weapongenerator.lua"
|
||||
|
||||
|
||||
def parsing_file(f):
|
||||
@@ -42,10 +35,24 @@ def parsing_file(f):
|
||||
return _to_translate
|
||||
|
||||
|
||||
for _str in parsing_file(name):
|
||||
test = re.findall('= "(.*[^/])(?: /\* (.*)\*/)?"%_[t|T]', _str)
|
||||
# print(test)
|
||||
def pars_file(name: str) -> list:
|
||||
"""
|
||||
:param name: name of file
|
||||
:return:
|
||||
"""
|
||||
list_to_translate: list = []
|
||||
for _str in parsing_file(name):
|
||||
string_to_translate = re.findall('= "(.*[^/])(?: /\* (.*)\*/)?"%_[t|T]', _str)
|
||||
list_to_translate.append(string_to_translate)
|
||||
return list_to_translate
|
||||
|
||||
|
||||
def all_to_translate():
|
||||
pass
|
||||
_files = scan_files(r'C:/Users/riksl/PycharmProjects/weapon-project-extended/')
|
||||
print(_files)
|
||||
# for _file in _files:
|
||||
# _strings = pars_file(_file)
|
||||
# print(_strings)
|
||||
|
||||
if __name__ == '__main__':
|
||||
all_to_translate()
|
||||
|
||||
Reference in New Issue
Block a user