lots of new littles things. Better wip management
This commit is contained in:
parent
0bc41f2660
commit
9a407e8e61
|
@ -54,7 +54,9 @@ options = {
|
|||
'-R' : "Remove", 'remove' : "Remove",
|
||||
'-n' : "New", 'new' : "New",
|
||||
'-e' : "Edit", 'edit' : "Edit",
|
||||
'-F' : "Force", 'force' : "Force"
|
||||
'-F' : "Force", 'force' : "Force",
|
||||
'-s' : "Show",
|
||||
'-d' : 'DB'
|
||||
}
|
||||
|
||||
# Set Argument 2 or 3
|
||||
|
|
|
@ -28,6 +28,7 @@ import tyto
|
|||
if tyto.domain_exists: exec(open(tyto.domain_conf).read())
|
||||
|
||||
post_err = False
|
||||
date_wip = hash_wip = date_www = hash_www = ''
|
||||
|
||||
|
||||
#=========================#
|
||||
|
@ -48,8 +49,20 @@ def manage_check(target, option):
|
|||
if option == 'Edit':
|
||||
tyto.edit_file(tyto.uri_root)
|
||||
return
|
||||
elif option == 'Show':
|
||||
article_raw = open(tyto.uri_root).read()
|
||||
for line in article_raw.rsplit('\n'):
|
||||
print(line)
|
||||
return
|
||||
|
||||
if db_exists:
|
||||
# Just read the DB from command
|
||||
if option == 'DB':
|
||||
article_db = open(tyto.post_db).read()
|
||||
for line in article_db.rsplit('\n'):
|
||||
print(line)
|
||||
return
|
||||
|
||||
try:
|
||||
exec(open(tyto.post_db).read(),globals())
|
||||
try:
|
||||
|
@ -64,6 +77,7 @@ def manage_check(target, option):
|
|||
|
||||
# Specific to inline-code: check markers on same line
|
||||
check_icodes(article.rsplit('\n'))
|
||||
|
||||
# Protect inline-codes
|
||||
tyto.protect_icodes(post_bottom, article_bottom)
|
||||
post_bottom = tyto.protect_article.rsplit('\n')
|
||||
|
@ -609,12 +623,13 @@ def create_database():
|
|||
'wip_uri = "%s%s"\n'%(srv_wip, web_uri) + \
|
||||
'www_uri = "%s%s"\n'%(srv_www, web_uri) + \
|
||||
'http_uri = "%s"\n'%tyto.web_uri + \
|
||||
'\n' + \
|
||||
'date_chk = "%s"\n'%tyto.nowdate() + \
|
||||
'hash_chk = "%s"\n'%tyto.hash_post + \
|
||||
'date_wip = ""\n' + \
|
||||
'hash_wip = ""\n' + \
|
||||
'date_www = ""\n' + \
|
||||
'hash_www = ""\n' + \
|
||||
'date_wip = "%s"\n'%date_wip + \
|
||||
'hash_wip = "%s"\n'%hash_wip + \
|
||||
'date_www = "%s"\n'%date_www + \
|
||||
'hash_www = "%s"\n'%hash_www + \
|
||||
'\n# Post configuration from needed tags\n' + \
|
||||
'title = "%s"\n'%title + \
|
||||
'about = "%s"\n'%about + \
|
||||
|
|
|
@ -29,7 +29,7 @@ def manage_domain(target, option):
|
|||
print(":D Edit domain configuration file:", tyto.domain_conf)
|
||||
tyto.edit_file(tyto.domain_conf)
|
||||
|
||||
if option == 'New':
|
||||
elif option == 'New':
|
||||
if not tyto.domain_exists:
|
||||
create_domain(target)
|
||||
else:
|
||||
|
@ -38,6 +38,12 @@ def manage_domain(target, option):
|
|||
if ask in ['y', 'Y']: create_domain(target)
|
||||
else: tyto.exiting("255", '', True)
|
||||
|
||||
elif option == 'DB' or option == 'Show':
|
||||
if tyto.domain_exists:
|
||||
domain_db = open(tyto.domain_conf).read()
|
||||
for line in domain_db.rsplit('\n'):
|
||||
print(line)
|
||||
|
||||
|
||||
#=====================#
|
||||
# Check target if URL #
|
||||
|
|
|
@ -392,18 +392,19 @@ def protect_bcodes_quotes(process, post_bottom, article_bottom):
|
|||
|
||||
# Count titles for check
|
||||
# Pass if line is a comment
|
||||
if not in_bcode or not in_quote:
|
||||
if not in_bcode and not in_quote:
|
||||
if line.startswith(titles_tags):
|
||||
if process == 'check':
|
||||
nbr_titles += 1
|
||||
elif line.startswith('#'):
|
||||
continue
|
||||
continue
|
||||
|
||||
if in_bcode:
|
||||
if not bcode: bcode = line
|
||||
else: bcode = '%s\n%s'%(bcode, line)
|
||||
|
||||
elif in_quote:
|
||||
if line.startswith('#'): continue
|
||||
if not quote: quote = line
|
||||
else: quote = '%s\n%s'%(quote, line)
|
||||
|
||||
|
@ -482,13 +483,13 @@ def exiting(nbr, value, out):
|
|||
'6' : ':< %sUnused "%s"%s in article'%(CR, CS, value),
|
||||
'7' : ':< Article is %snot valid yet%s'%(CR, CS),
|
||||
'8' : ':< %sNot paired%s: %s'%(CR, CS, value),
|
||||
'9' : ':D Article has changed (wip is old)',
|
||||
'9' : ':< Article %shas changed%s. Check it first'%(CR, CS),
|
||||
'10' : ':< %sUnused "%s"%s in article\'s header'%(CR, value, CS),
|
||||
'20' : ':D %sUp-to-date%s article on: %s'%(CG, CS, value),
|
||||
'21' : ':D %sValid%s article to wip'%(CG, CS),
|
||||
'21' : ':D %sValid%s article. Ready to wip'%(CG, CS),
|
||||
'22' : ':? %sNot paired%s symbols: %s'%(CY, CS, value),
|
||||
'23' : ':? %sCorrupted database%s: %s'%(CY, CS, value),
|
||||
'24' : ':? %sMissing wip file%s: %s'%(CY, CS, value),
|
||||
'24' : ':? %sfile missing%s (wip article): %s'%(CY, CS, value),
|
||||
'255' : ':| Maybe later...'
|
||||
}
|
||||
|
||||
|
|
|
@ -29,33 +29,26 @@ def manage_wip(target, option):
|
|||
if not db_exists:
|
||||
tyto.exiting("4", '', True)
|
||||
|
||||
# Has DB: conditions to process
|
||||
is_wip = True
|
||||
is_new = False
|
||||
is_file = True
|
||||
do_wip = False
|
||||
|
||||
# Load DB
|
||||
exec(open(tyto.post_db).read(),globals())
|
||||
|
||||
# Exit if article has changed
|
||||
if hash_chk != tyto.hash_post: tyto.exiting("9", '', True)
|
||||
|
||||
# In any case, if Force
|
||||
if option == 'Force':
|
||||
wip_article(target)
|
||||
return
|
||||
|
||||
# Compare and check file
|
||||
if not hash_wip == hash_chk: is_wip = False ; do_wip = True
|
||||
if not hash_wip == tyto.hash_post: is_new = True ; do_wip = True
|
||||
if not os.path.exists(wip_uri): is_file = False ; do_wip = True
|
||||
|
||||
if do_wip:
|
||||
# Show message if wip was done
|
||||
if hash_wip:
|
||||
if not is_file: tyto.exiting("24", wip_uri, False)
|
||||
if is_new: tyto.exiting("9", '', False)
|
||||
if hash_wip != hash_chk:
|
||||
wip_article(target)
|
||||
else:
|
||||
tyto.exiting("20", date_wip, True)
|
||||
if not os.path.exists(wip_uri):
|
||||
tyto.exiting("24", wip_uri, False)
|
||||
wip_article(target)
|
||||
else:
|
||||
tyto.exiting("20", date_wip, True)
|
||||
|
||||
|
||||
#===================#
|
||||
|
|
Loading…
Reference in New Issue