Some works to do on command arguments. New help with tyto command
This commit is contained in:
parent
601f56d7af
commit
a0c6366113
|
@ -38,21 +38,25 @@ import args
|
||||||
action = args.set_action()
|
action = args.set_action()
|
||||||
target = args.set_target()
|
target = args.set_target()
|
||||||
|
|
||||||
import check, domain, html, new, publish, show, wip
|
import check, domain, html, new, publish, show, wip, infos
|
||||||
|
|
||||||
# Command start argument
|
# Command start argument
|
||||||
actions = {
|
actions = {
|
||||||
'check' : check.manage_check,
|
'check' : check.manage_check,
|
||||||
'domain' : domain.manage_domain,
|
'help' : infos.tyto,
|
||||||
'edit' : show.manage_show,
|
'edit' : show.manage_show,
|
||||||
'editdb' : show.manage_show,
|
'edit-db' : show.manage_show,
|
||||||
|
'edit-wip' : show.manage_show,
|
||||||
|
'edit-www' : show.manage_show,
|
||||||
'footer' : html.manage_configs,
|
'footer' : html.manage_configs,
|
||||||
'metas' : html.manage_configs,
|
'metas' : html.manage_configs,
|
||||||
'navbar' : html.manage_configs,
|
'navbar' : html.manage_configs,
|
||||||
'new' : new.manage_new,
|
'new' : new.manage_new,
|
||||||
'publish' : publish.manage_publish,
|
'publish' : publish.manage_publish,
|
||||||
'show' : show.manage_show,
|
'show' : show.manage_show,
|
||||||
'showdb' : show.manage_show,
|
'show-db' : show.manage_show,
|
||||||
|
'show-wip' : show.manage_show,
|
||||||
|
'show-www' : show.manage_show,
|
||||||
'sidebar' : html.manage_configs,
|
'sidebar' : html.manage_configs,
|
||||||
'wip' : wip.manage_wip
|
'wip' : wip.manage_wip
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,24 +18,30 @@
|
||||||
#**********************************************************************
|
#**********************************************************************
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import infos
|
||||||
|
|
||||||
# Arguments from command line
|
# Arguments from command line
|
||||||
|
# tyto [action] [target]
|
||||||
#----------------------------
|
#----------------------------
|
||||||
# Dict for Actions
|
|
||||||
actions = (
|
actions = (
|
||||||
'check',
|
'check',
|
||||||
'domain',
|
|
||||||
'edit',
|
'edit',
|
||||||
'editdb',
|
'edit-db',
|
||||||
|
'edit-wip',
|
||||||
|
'edit-www',
|
||||||
|
'help',
|
||||||
'new',
|
'new',
|
||||||
'show',
|
'show',
|
||||||
'showdb',
|
'show-db',
|
||||||
|
'show-wip',
|
||||||
|
'show-www',
|
||||||
'wip',
|
'wip',
|
||||||
'publish'
|
'publish'
|
||||||
)
|
)
|
||||||
|
|
||||||
pass_actions = (
|
pass_actions = (
|
||||||
'new'
|
'new'
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
pass_targets = (
|
pass_targets = (
|
||||||
|
@ -48,28 +54,28 @@ pass_targets = (
|
||||||
|
|
||||||
action = ''
|
action = ''
|
||||||
target = ''
|
target = ''
|
||||||
|
noaction = False
|
||||||
|
|
||||||
# action
|
# action
|
||||||
#-------
|
#-------
|
||||||
try:
|
try: action = sys.argv[1]
|
||||||
sys.argv[1]
|
except: noaction = True
|
||||||
action = sys.argv[1]
|
|
||||||
except:
|
if noaction:
|
||||||
print(':< Needed [action] argument')
|
infos.tyto(target)
|
||||||
sys.exit(1)
|
sys.exit(0)
|
||||||
|
|
||||||
if not action in actions:
|
if not action in actions:
|
||||||
print(':< Unused [action] argument: "%s"'%sys.argv[1])
|
print(':< Unused [action] argument: "%s"'%action)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
# target
|
# target
|
||||||
#-------
|
#-------
|
||||||
try:
|
try: target = sys.argv[2]
|
||||||
sys.argv[2]
|
except: target = ''
|
||||||
target = sys.argv[2]
|
|
||||||
except:
|
|
||||||
target = ''
|
|
||||||
|
|
||||||
|
# Set action and target for binary
|
||||||
def set_action():
|
def set_action():
|
||||||
return(action)
|
return(action)
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ domain_values = (
|
||||||
)
|
)
|
||||||
|
|
||||||
# If error in DB, continue process for these options
|
# If error in DB, continue process for these options
|
||||||
domain_pass_args = ('New', 'Edit', 'Show', '')
|
domain_pass_args = ('new', 'edit', 'show', '')
|
||||||
|
|
||||||
# Search and set domain conf file
|
# Search and set domain conf file
|
||||||
# from current directory or from argument
|
# from current directory or from argument
|
||||||
|
|
|
@ -503,38 +503,32 @@ def create_domain(target):
|
||||||
# sidebar load file translated #
|
# sidebar load file translated #
|
||||||
#------------------------------#
|
#------------------------------#
|
||||||
def create_sidebar(option):
|
def create_sidebar(option):
|
||||||
if not db.domain_active: return
|
# Check if can process
|
||||||
|
if not db.domain_exists \
|
||||||
|
or db.incomplete_domain \
|
||||||
|
or not db.domain_active:
|
||||||
|
return
|
||||||
|
|
||||||
# Create an empty html file if not exists
|
# Create an empty html file if not exists
|
||||||
|
try:
|
||||||
if not os.path.exists(db.wip_sidebar):
|
if not os.path.exists(db.wip_sidebar):
|
||||||
tyto.set_file(db.wip_sidebar, 'new', '')
|
tyto.set_file(db.wip_sidebar, 'new', '')
|
||||||
print(' ├ Create file: %s'%db.wip_sidebar)
|
print(' ├ Create empty file: %s'%db.wip_sidebar)
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
logs.out("4", db.wip_sidebar, True)
|
||||||
|
|
||||||
create_load = False # file in _configs
|
# Create new file, or ask if exists
|
||||||
create_html = False # file in template/
|
ask = ' ├ Reset sidebar configuration file ? '
|
||||||
|
log = ' ├ Create source file: %s'%db.sidebar_load
|
||||||
# Get metas_load hash or create metas db file if not exists
|
res = ''
|
||||||
#----------------------------------------------------------
|
|
||||||
if os.path.exists(db.sidebar_load):
|
if os.path.exists(db.sidebar_load):
|
||||||
html.create_db_load(db.sidebar_load, db.sidebar_load_db)
|
try:
|
||||||
|
res = input(ask)
|
||||||
# Manage option
|
except KeyboardInterrupt:
|
||||||
#--------------
|
print('')
|
||||||
if not os.path.exists(db.sidebar_load):
|
logs.out("255", '', True)
|
||||||
create_load = True
|
if not res in ['y', 'Y']: return
|
||||||
elif option == 'New':
|
|
||||||
create_load = True
|
|
||||||
elif option == 'Create':
|
|
||||||
create_html = True
|
|
||||||
elif option == 'Edit':
|
|
||||||
hash_load_old = tyto.get_filesum(db.sidebar_load, True)
|
|
||||||
tyto.edit_file(db.sidebar_load)
|
|
||||||
hash_load_new = tyto.get_filesum(db.sidebar_load, True)
|
|
||||||
if not hash_load_old == hash_load_new:
|
|
||||||
html.create_db_load(db.sidebar_load, db.sidebar_load_db)
|
|
||||||
create_html = True
|
|
||||||
elif option == 'Force':
|
|
||||||
create_load = True
|
|
||||||
|
|
||||||
# French sidebar_load content
|
# French sidebar_load content
|
||||||
sdb_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
sdb_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
||||||
|
@ -572,13 +566,30 @@ def create_sidebar(option):
|
||||||
if tyto.n == 0: sdb_load = sdb_load_fr
|
if tyto.n == 0: sdb_load = sdb_load_fr
|
||||||
elif tyto.n == 1: sdb_load = sdb_load_en
|
elif tyto.n == 1: sdb_load = sdb_load_en
|
||||||
|
|
||||||
# Create sidebar_load
|
tyto.set_file(db.sidebar_load, 'new', sdb_load)
|
||||||
if create_load:
|
print(log)
|
||||||
|
|
||||||
|
|
||||||
|
#=============================#
|
||||||
|
# navbar load file translated #
|
||||||
|
#-----------------------------#
|
||||||
|
def create_navbar(option):
|
||||||
|
# Check if can process
|
||||||
|
if not db.domain_exists \
|
||||||
|
or db.incomplete_domain \
|
||||||
|
or not db.domain_active:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Create an empty html file if not exists
|
||||||
|
if not os.path.exists(db.wip_navbar):
|
||||||
|
tyto.set_file(db.wip_navbar, 'new', '')
|
||||||
|
print(' ├ Create empty file: %s'%db.wip_navbar)
|
||||||
|
|
||||||
# Create new file, or ask if exists
|
# Create new file, or ask if exists
|
||||||
ask = ' ├ Reset sidebar configuration file ? '
|
ask = ' ├ Reset navbar configuration file ? '
|
||||||
log = ' ├ Create file: %s'%db.sidebar_load
|
log = ' ├ Create source file: %s'%db.navbar_load
|
||||||
res = ''
|
res = ''
|
||||||
if os.path.exists(db.sidebar_load):
|
if os.path.exists(db.navbar_load):
|
||||||
try:
|
try:
|
||||||
res = input(ask)
|
res = input(ask)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -586,52 +597,8 @@ def create_sidebar(option):
|
||||||
logs.out("255", '', True)
|
logs.out("255", '', True)
|
||||||
if not res in ['y', 'Y']: return
|
if not res in ['y', 'Y']: return
|
||||||
|
|
||||||
tyto.set_file(db.sidebar_load, 'new', sdb_load)
|
|
||||||
print(log)
|
|
||||||
html.create_db_load(db.sidebar_load, db.sidebar_load_db)
|
|
||||||
|
|
||||||
# Create wip/template/sidebar.html
|
|
||||||
if create_html:
|
|
||||||
html.create_sidebar(db.wip_sidebar)
|
|
||||||
|
|
||||||
|
|
||||||
#=============================#
|
|
||||||
# navbar load file translated #
|
|
||||||
#-----------------------------#
|
|
||||||
def create_navbar(option):
|
|
||||||
if not db.domain_active: return
|
|
||||||
|
|
||||||
# Create an empty html file if not exists
|
|
||||||
if not os.path.exists(db.wip_navbar):
|
|
||||||
tyto.set_file(db.wip_navbar, 'new', '')
|
|
||||||
print(' ├ Create file: %s'%db.wip_navbar)
|
|
||||||
|
|
||||||
create_load = False # file in _configs
|
|
||||||
create_html = False # file in template/
|
|
||||||
|
|
||||||
# Get metas_load hash or create metas db file if not exists
|
|
||||||
#----------------------------------------------------------
|
|
||||||
if os.path.exists(db.navbar_load):
|
|
||||||
html.create_db_load(db.navbar_load, db.navbar_load_db)
|
|
||||||
|
|
||||||
# Manage option
|
|
||||||
#--------------
|
|
||||||
if not os.path.exists(db.navbar_load):
|
|
||||||
create_load = True
|
|
||||||
elif option == 'New':
|
|
||||||
create_load = True
|
|
||||||
elif option == 'Create':
|
|
||||||
create_html = True
|
|
||||||
elif option == 'Edit':
|
|
||||||
hash_load_old = tyto.get_filesum(db.navbar_load, True)
|
|
||||||
tyto.edit_file(db.navbar_load)
|
|
||||||
hash_load_new = tyto.get_filesum(db.navbar_load, True)
|
|
||||||
if not hash_load_old == hash_load_new:
|
|
||||||
html.create_db_load(db.navbar_load, db.navbar_load_db)
|
|
||||||
create_html = True
|
|
||||||
elif option == 'Force':
|
|
||||||
create_load = True
|
|
||||||
|
|
||||||
|
# French navbar_load content
|
||||||
nav_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
nav_load_fr = '# Pour : Tyto - Littérateur\n' + \
|
||||||
'# Type : fichier texte\n' + \
|
'# Type : fichier texte\n' + \
|
||||||
'# Description : Fichier utilisé par "tyto wip"\n' + \
|
'# Description : Fichier utilisé par "tyto wip"\n' + \
|
||||||
|
@ -653,6 +620,7 @@ def create_navbar(option):
|
||||||
'# a-propos # Informations concernant ce site\n' + \
|
'# a-propos # Informations concernant ce site\n' + \
|
||||||
'# %s\n\n'%(15 * "-")
|
'# %s\n\n'%(15 * "-")
|
||||||
|
|
||||||
|
# English navbar_load content
|
||||||
nav_load_en = '# For: Tyto - Littérateur\n' + \
|
nav_load_en = '# For: Tyto - Littérateur\n' + \
|
||||||
'# Type: Text file\n' + \
|
'# Type: Text file\n' + \
|
||||||
'# Description: file used with "tyto wip"\n' + \
|
'# Description: file used with "tyto wip"\n' + \
|
||||||
|
@ -678,24 +646,5 @@ def create_navbar(option):
|
||||||
if tyto.n == 0: nvb_load = nav_load_fr
|
if tyto.n == 0: nvb_load = nav_load_fr
|
||||||
elif tyto.n == 1: nvb_load = nav_load_en
|
elif tyto.n == 1: nvb_load = nav_load_en
|
||||||
|
|
||||||
# Create sidebar_load
|
|
||||||
if create_load:
|
|
||||||
# Create new file, or ask if exists
|
|
||||||
ask = ' ├ Reset navbar configuration file ? '
|
|
||||||
log = ' ├ Create file: %s'%db.navbar_load
|
|
||||||
res = ''
|
|
||||||
if os.path.exists(db.navbar_load):
|
|
||||||
try:
|
|
||||||
res = input(ask)
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print('')
|
|
||||||
logs.out("255", '', True)
|
|
||||||
if not res in ['y', 'Y']: return
|
|
||||||
|
|
||||||
tyto.set_file(db.navbar_load, 'new', nvb_load)
|
tyto.set_file(db.navbar_load, 'new', nvb_load)
|
||||||
print(log)
|
print(log)
|
||||||
html.create_db_load(db.navbar_load, db.navbar_load_db)
|
|
||||||
|
|
||||||
# Create wip/template/sidebar.html
|
|
||||||
if create_html:
|
|
||||||
html.create_navbar(db.wip_navbar)
|
|
||||||
|
|
|
@ -249,7 +249,17 @@ def create_db_load(file_load, file_db):
|
||||||
# Create HTML sidebar from file tyto.sidebar #
|
# Create HTML sidebar from file tyto.sidebar #
|
||||||
#--------------------------------------------#
|
#--------------------------------------------#
|
||||||
def create_sidebar(target):
|
def create_sidebar(target):
|
||||||
if not db.domain_exists: return
|
# Check if can process
|
||||||
|
if not db.domain_exists \
|
||||||
|
or db.incomplete_domain \
|
||||||
|
or not db.domain_active:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
db.sidebar_load
|
||||||
|
if not os.path.exists(db.sidebar_load):
|
||||||
|
logs.out("1", db.sidebar_load, True)
|
||||||
|
except:
|
||||||
|
logs.out("1", 'Sidebar source file', True)
|
||||||
|
|
||||||
# If content in sidebar, go True
|
# If content in sidebar, go True
|
||||||
sidebar_new = False
|
sidebar_new = False
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# Name: Tyto - Littérateur
|
||||||
|
# Type: Show infos about Tyto
|
||||||
|
# Description: Show informations about Tyto - Littérateur
|
||||||
|
# file: infos.py
|
||||||
|
# Folder: /var/lib/tyto/program/
|
||||||
|
# By echolib (XMPP: im@echolib.re)
|
||||||
|
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||||
|
|
||||||
|
#------------
|
||||||
|
# funny stats
|
||||||
|
#------------
|
||||||
|
# lines:
|
||||||
|
# functions:
|
||||||
|
# comments:
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#**********************************************************************
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
def tyto(target):
|
||||||
|
noinfos = False
|
||||||
|
|
||||||
|
# Show Version
|
||||||
|
try:
|
||||||
|
if os.path.exists('/usr/bin/tyto'):
|
||||||
|
tytobin = open('/usr/bin/tyto').read()
|
||||||
|
for line in tytobin.rsplit('\n'):
|
||||||
|
if line.startswith('# Version:'):
|
||||||
|
print(line)
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
noinfo = True
|
||||||
|
print(':< No /usr/bin/tyto')
|
||||||
|
|
||||||
|
# Show domains list
|
||||||
|
try:
|
||||||
|
db_domains = '%s/.local/tyto'%os.path.expanduser('~')
|
||||||
|
user = os.environ.get('USER')
|
||||||
|
hashdomain = False
|
||||||
|
for folder in os.listdir(db_domains):
|
||||||
|
if os.path.isdir('%s/%s'%(db_domains, folder)):
|
||||||
|
if hashdomain:
|
||||||
|
hasdomain = False
|
||||||
|
hashdomain = True
|
||||||
|
print('# Registred domains for', user)
|
||||||
|
print('-', folder)
|
||||||
|
|
||||||
|
except:
|
||||||
|
noinfo = True
|
||||||
|
print(':< No .../.local/tyto')
|
||||||
|
|
||||||
|
# Show Usage
|
||||||
|
print(
|
||||||
|
'\nUsage: tyto [action] [target] \n'
|
||||||
|
' After created domain (tyto new domain [URL]),\n'
|
||||||
|
' create article\'s file in articles/ directory,\n'
|
||||||
|
' do in this order on [target] file: Check > wip > publish\n\n'
|
||||||
|
'- [action] according to [target]:\n'
|
||||||
|
' edit : Edit article\'s source file\n'
|
||||||
|
' edit-db : Edit post or domain database\n'
|
||||||
|
' edit-wip: Edit html file in wip server\n'
|
||||||
|
' edit_www: Edit html file in www server\n'
|
||||||
|
' new : Create new (domain, sidebar/footer... config file)\n'
|
||||||
|
' show : Show content of source file\n'
|
||||||
|
' show-db : Show content of post or domain database\n'
|
||||||
|
' show-wip: Show html file in wip server\n'
|
||||||
|
' show-www: Show html file in www server\n\n'
|
||||||
|
' check : Check if article is valid\n'
|
||||||
|
' wip : Create page in wip server\n'
|
||||||
|
' publish : Create page in www server\n\n'
|
||||||
|
'- [target] according to [action]\n' + \
|
||||||
|
' [file] : File uri of an article\n'
|
||||||
|
' footer : Create footer config/HTML code file\n'
|
||||||
|
' metas : Create metas config/HTML code file\n'
|
||||||
|
' navbar : Create navbar config/HTML code file\n'
|
||||||
|
' sidebar : Create sidebar config/HTML code file\n\n'
|
||||||
|
'# Examples:\n'
|
||||||
|
' tyto new sidebar: create default source file /_configs/tyto.sidebar\n'
|
||||||
|
' tyto publish sidebar: create code file in www server for pages\n'
|
||||||
|
' tyto edit-wip navbar: edit file: /wip/template/navbar.html\n'
|
||||||
|
' tyto edit navbar: edit /_configs/tyto.navbar\n'
|
||||||
|
)
|
|
@ -61,7 +61,7 @@ def out(nbr, value, out):
|
||||||
'41' : ':? %sIncomplete%s domain "%s"'%(CR, CS, value),
|
'41' : ':? %sIncomplete%s domain "%s"'%(CR, CS, value),
|
||||||
'42' : ':D %sActive%s domain "%s"'%(CG, CS, value),
|
'42' : ':D %sActive%s domain "%s"'%(CG, CS, value),
|
||||||
'43' : ':? %sNo domain%s configured here: %s'%(CY, CS, value),
|
'43' : ':? %sNo domain%s configured here: %s'%(CY, CS, value),
|
||||||
'51' : ':< %sIncomplete data%s: %s'%(CY, CS, value),
|
'51' : ':? %sIncomplete data%s: %s'%(CY, CS, value),
|
||||||
'255' : ';) Maybe later...'
|
'255' : ';) Maybe later...'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,13 @@ import logs, args, db, domain
|
||||||
#-----------------------------------------------#
|
#-----------------------------------------------#
|
||||||
def manage_new(target):
|
def manage_new(target):
|
||||||
if target == "domain":
|
if target == "domain":
|
||||||
try: target = sys.argv[3]
|
try: URL = sys.argv[3]
|
||||||
except: target = ''
|
except: URL = ''
|
||||||
domain.manage_domain(target)
|
domain.manage_domain(URL)
|
||||||
|
|
||||||
|
elif target == 'sidebar':
|
||||||
|
domain.create_sidebar(target)
|
||||||
|
|
||||||
|
elif target == 'navbar':
|
||||||
|
domain.create_navbar(target)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#**********************************************************************
|
#**********************************************************************
|
||||||
|
|
||||||
import importlib
|
import os, importlib
|
||||||
import args, db, logs, tyto, check
|
import args, db, logs, tyto, check
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,52 +32,57 @@ def manage_show(target):
|
||||||
# Domain configuration must exists
|
# Domain configuration must exists
|
||||||
if not db.domain_exists: sys.exit(43)
|
if not db.domain_exists: sys.exit(43)
|
||||||
|
|
||||||
# Conditions to filter processes show, or edit
|
do = False
|
||||||
actions_target_ct = ('show', 'edit')
|
actions_read = ('show', 'show-db', 'show-wip', 'show-www')
|
||||||
actions_target_db = ('showdb', 'editdb')
|
actions_edit = ('edit', 'edit-db', 'edit-wip', 'edit-www')
|
||||||
actions_read = ('show', 'showdb')
|
|
||||||
actions_edit = ('edit', 'editdb')
|
|
||||||
|
|
||||||
# target in command is an uri file
|
actions_wip = ('show-wip', 'edit-wip')
|
||||||
if args.action in actions_target_ct and db.post_exists:
|
actions_www = ('show-www', 'edit-www')
|
||||||
target = "post"
|
|
||||||
do = {"post" : db.uri_file}
|
actions_post = ('show', 'edit')
|
||||||
|
actions_db = ('show-db', 'edit-db')
|
||||||
|
|
||||||
|
# Target is not a post uri (sidebar, navbar, metas, footer)
|
||||||
|
#----------------------------------------------------------
|
||||||
|
if target in args.pass_targets:
|
||||||
|
if args.action in actions_post:
|
||||||
|
do = {
|
||||||
|
"domain" : db.domain_conf,
|
||||||
|
"footer" : db.footer_load,
|
||||||
|
"metas" : db.metas_load,
|
||||||
|
"navbar" : db.navbar_load,
|
||||||
|
"sidebar" : db.sidebar_load
|
||||||
|
}
|
||||||
|
|
||||||
|
# Target is a post uri
|
||||||
|
#---------------------
|
||||||
|
elif db.uri_file:
|
||||||
|
|
||||||
# Get hash when edit to ask to check again if change
|
# Get hash when edit to ask to check again if change
|
||||||
if args.action == "edit":
|
if args.action == "edit":
|
||||||
curr_hash = tyto.get_filesum(db.uri_file, True)
|
curr_hash = tyto.get_filesum(db.uri_file, True)
|
||||||
|
|
||||||
# Set DB from article
|
if args.action in actions_post:
|
||||||
elif args.action in actions_target_db and db.db_exists:
|
|
||||||
target = "post"
|
target = "post"
|
||||||
do = {"post" : db.post_db}
|
do = {"post" : db.uri_file}
|
||||||
|
|
||||||
# Target is a registred name to access file
|
# Post has database
|
||||||
elif target in args.pass_targets:
|
elif db.db_exists:
|
||||||
try:
|
if args.action in actions_wip:
|
||||||
# File is a "db" from showdb, editdb
|
target = "wip"
|
||||||
if args.action in actions_target_db:
|
do = {"wip" : db.post_wip}
|
||||||
do = {
|
|
||||||
'domain' : db.domain_conf,
|
|
||||||
'footer' : db.footer_load,
|
|
||||||
'metas' : db.metas_load,
|
|
||||||
'navbar' : db.navbar_load,
|
|
||||||
'sidebar' : db.sidebar_load,
|
|
||||||
}
|
|
||||||
|
|
||||||
# File is a source, or final file from show, edit
|
elif args.action in actions_www:
|
||||||
elif args.action in actions_target_ct:
|
target = "www"
|
||||||
do = {
|
do = {"www" : db.post_www}
|
||||||
'domain' : db.domain_conf,
|
|
||||||
'footer' : db.wip_footer,
|
elif args.action in actions_db:
|
||||||
'metas' : db.wip_metas,
|
target = "db"
|
||||||
'navbar' : db.wip_navbar,
|
do = {"db" : db.post_db}
|
||||||
'sidebar' : db.wip_sidebar,
|
|
||||||
}
|
#print('> show: target', target)
|
||||||
except:
|
|
||||||
logs.out("41", '%s configuration'%target, True)
|
if not do: logs.out("28", 'yet', True)
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Read lines of, or edit file
|
# Read lines of, or edit file
|
||||||
if args.action in actions_read: read_lines(do[target])
|
if args.action in actions_read: read_lines(do[target])
|
||||||
|
@ -106,6 +111,7 @@ def manage_show(target):
|
||||||
#--------------------------------------------#
|
#--------------------------------------------#
|
||||||
def read_lines(f):
|
def read_lines(f):
|
||||||
if not f: return # Maybe
|
if not f: return # Maybe
|
||||||
|
if not os.path.exists(f): logs.out("1", f, True)
|
||||||
|
|
||||||
datas = open(f).read()
|
datas = open(f).read()
|
||||||
for line in datas.rsplit('\n'):
|
for line in datas.rsplit('\n'):
|
||||||
|
|
Loading…
Reference in New Issue