From f4199d5ad3b554f307231219a4535ffe0df1018e Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Mon, 27 May 2024 14:39:44 +0200 Subject: [PATCH] Fixes in regular expressions --- paramecio2/console.py | 10 ++++++---- paramecio2/libraries/check_i18n.py | 12 ++++++------ paramecio2/libraries/db/extrafields/emailfield.py | 2 +- paramecio2/libraries/db/extrafields/urlfield.py | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/paramecio2/console.py b/paramecio2/console.py index 2b8bfde..ded9755 100755 --- a/paramecio2/console.py +++ b/paramecio2/console.py @@ -41,7 +41,7 @@ def start(): parser.add_argument('--symlink', help='Set if create direct symlink to paramecio in new site', action='store_true') - parser.add_argument('--tests', help='Create a symlink to tests for check into paramecio site', action='store_true') + #parser.add_argument('--tests', help='Create a symlink to tests for check into paramecio site', action='store_true') # Options for deploy @@ -49,9 +49,9 @@ def start(): parser.add_argument('--folder', help='If you deploy in a subdirectory, set it, without beggining and ending slashes', required=False) - parser.add_argument('--host', help='The host ip or domain where the app is binded', required=False) + #parser.add_argument('--host', help='The host ip or domain where the app is binded', required=False) - parser.add_argument('--port', help='Change the default port 8080 to other number. Use 80 is not recommended, use 80 for the proxy server how nginx or apache', required=False) + #parser.add_argument('--port', help='Change the default port 8080 to other number. Use 80 is not recommended, use 80 for the proxy server how nginx or apache', required=False) args=parser.parse_args() @@ -106,13 +106,15 @@ def start(): except: print('Error: cannot symlink paramecio in new site') - + + """ if args.tests==True: try: os.symlink(workdir, args.path+'/paramecio2/', True) except: print('Error: cannot symlink paramecio2 in new site') + """ with open(path_settings+'/config.py', 'r') as f: conf=f.read() diff --git a/paramecio2/libraries/check_i18n.py b/paramecio2/libraries/check_i18n.py index 75cbd58..0a826f0 100644 --- a/paramecio2/libraries/check_i18n.py +++ b/paramecio2/libraries/check_i18n.py @@ -38,12 +38,12 @@ except: """Command line utility for extract I18n.lang strings from html templates and .py files """ -pattern=re.compile('^\w+\.(py|html|phtml|js)$') +pattern=re.compile(r'^\w+\.(py|html|phtml|js)$') -ignored=re.compile('^[__|\.].*$') +ignored=re.compile(r'^[__|\.].*$') -lang_p=re.compile("I18n\.lang\('(.*?)',\s+'(.*?)',\s+'(.*?)'\)") -lang_t=re.compile("\${lang\('(.*?)',\s+'(.*?)',\s+'(.*?)'\)\}") +lang_p=re.compile(r"I18n\.lang\('(.*?)',\s+'(.*?)',\s+'(.*?)'\)") +lang_t=re.compile(r"\${lang\('(.*?)',\s+'(.*?)',\s+'(.*?)'\)\}") tmp_lang={} @@ -76,9 +76,9 @@ def start(): module_base=os.path.basename(args.module) - lang_p=re.compile("I18n\.lang\('("+module_base+"?)',\s+'(.*?)',\s+'(.*?)'\)") + lang_p=re.compile(r"I18n\.lang\('("+module_base+r"?)',\s+'(.*?)',\s+'(.*?)'\)") #lang_t=re.compile("\${lang\('("+module_base+"?)',\s+'(.*?)',\s+'(.*?)'\)\}") - lang_t=re.compile("lang\('("+module_base+"?)',\s+'(.*?)',\s+'(.*?)'\)") + lang_t=re.compile(r"lang\('("+module_base+r"?)',\s+'(.*?)',\s+'(.*?)'\)") if not os.path.isdir(path): diff --git a/paramecio2/libraries/db/extrafields/emailfield.py b/paramecio2/libraries/db/extrafields/emailfield.py index 3473703..549068d 100644 --- a/paramecio2/libraries/db/extrafields/emailfield.py +++ b/paramecio2/libraries/db/extrafields/emailfield.py @@ -20,7 +20,7 @@ along with this program. If not, see . from paramecio2.libraries.db.corefields import CharField import re -mail_pattern=re.compile("\w[\w\.-]*@\w[\w\.-]+\.\w+") +mail_pattern=re.compile(r"\w[\w\.-]*@\w[\w\.-]+\.\w+") class EmailField(CharField): """Field for save and check email addreses""" diff --git a/paramecio2/libraries/db/extrafields/urlfield.py b/paramecio2/libraries/db/extrafields/urlfield.py index 5dad3fc..cc95fbe 100644 --- a/paramecio2/libraries/db/extrafields/urlfield.py +++ b/paramecio2/libraries/db/extrafields/urlfield.py @@ -45,7 +45,7 @@ class UrlField(CharField): return value -check_domain=re.compile('^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|([a-zA-Z0-9][a-zA-Z0-9-_]{1,61}[a-zA-Z0-9]))\.([a-zA-Z]{2,6}|[a-zA-Z0-9-]{2,30}\.[a-zA-Z]{2,3})$') +check_domain=re.compile(r'^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|([a-zA-Z0-9][a-zA-Z0-9-_]{1,61}[a-zA-Z0-9]))\.([a-zA-Z]{2,6}|[a-zA-Z0-9-]{2,30}\.[a-zA-Z]{2,3})$') class DomainField(CharField): """Field for check and save strings in domain internet format""" @@ -72,7 +72,7 @@ class DomainField(CharField): #^(https|ssh):\/\/([a-zA-Z0-9\-_]+@)?[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*(:[0-9]+)?\/[a-zA-Z0-9\-_]+(\/[a-zA-Z0-9\-_]+)*(\.git)?$ -check_git_url=re.compile('^(https|ssh):\/\/([a-zA-Z0-9\-_]+@)?[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*(:[a-zA-Z0-9\-_]+)?\/[a-zA-Z0-9\-_]+(\/[a-zA-Z0-9\-_]+)*(\.git)?$') +check_git_url=re.compile(r'^(https|ssh):\/\/([a-zA-Z0-9\-_]+@)?[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*(:[a-zA-Z0-9\-_]+)?\/[a-zA-Z0-9\-_]+(\/[a-zA-Z0-9\-_]+)*(\.git)?$') class GitUrlField(CharField):