| Trees | Indices | Help |
|
|---|
|
|
PYBAG - Crossplatform files synchronization and backup portable tools.
Version: 0.5.0
Author: Mazhugin Aleksey
Copyright: Copyright (c) 2019, Mazhugin Aleksey.
License: Copyright (c) 2007 ... 2019, Mazhugin Aleksey All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Mazhugin Aleksey nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
| command_class | |||
|
z_gp_class Global preferences saver class. |
|||
|
z_r Class for result return from commands. |
|||
|
|||
|
|||
|
|||
|
|||
| Class object or bool. |
|
||
| bool |
|
||
| bool |
|
||
| bool |
|
||
| bool |
|
||
| bool |
|
||
| bool |
|
||
|
|||
| str |
|
||
| dict |
|
||
|
|||
|
|||
|
|||
|
|||
| list |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
| list or None |
|
||
|
|||
| tuple |
|
||
| str |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
| stirng. |
|
||
|
|||
| bool |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
climenu = Menu for display in command line version in synchronization. |
|||
climenuhelp = Menu help for display in command line version in synchronization. |
|||
pagemenu =
|
|||
dir_root = Current path to pybag location (folder). |
|||
dir_files = Files folder. |
|||
dir_db = Data base file path. |
|||
dir_dbt = Data base temp file path. |
|||
dir_cfg = Configuration file path. |
|||
dir_cfgt = Configuration temp file path. |
|||
stdout_wrapper = termcolors.StreamProxy(None, True)
|
|||
BACKUPDIR = 16
|
|||
COL_FORMAT = 4
|
|||
COL_HEADING = 1
|
|||
COL_NAME = 0
|
|||
COL_VISIBLE = 2
|
|||
COL_WIDTH = 3
|
|||
CRC32BUF = 1048575
|
|||
DBBACKUP = 27
|
|||
DBBACKUPNO = False
|
|||
DBBACKUPYES = True
|
|||
DBBAGCRC32 = 104
|
|||
DBBAGFLAG = 101
|
|||
DBBAGLINK = 107
|
|||
DBBAGMDATE = 103
|
|||
DBBAGPATH = 106
|
|||
DBBAGREAD = 105
|
|||
DBBAGSIZE = 102
|
|||
DBCOMPARE = 18
|
|||
DBDBCRC32 = 304
|
|||
DBDBFLAG = 301
|
|||
DBDBLINK = 307
|
|||
DBDBMDATE = 303
|
|||
DBDBPATH = 306
|
|||
DBDBREAD = 305
|
|||
DBDBSIZE = 302
|
|||
DBDESC = 20
|
|||
DBDESCMAN = 22
|
|||
DBDESCMANNONE =
|
|||
DBDESCNONE =
|
|||
DBDESCOK =
|
|||
DBDESCREADED = 25
|
|||
DBDIR = 15
|
|||
DBDIRBAG = 1
|
|||
DBDIRCONFLICT = 64
|
|||
DBDIRCOPY = 8
|
|||
DBDIRDB = 4
|
|||
DBDIRDELETE = 16
|
|||
DBDIRDIFF = 4096
|
|||
DBDIRERROR = 128
|
|||
DBDIRFORCED = 1024
|
|||
DBDIRIGNORED = 2048
|
|||
DBDIRMAN = 21
|
|||
DBDIRNEW = 256
|
|||
DBDIRNONE = 0
|
|||
DBDIROK = 8192
|
|||
DBDIRORIG = 2
|
|||
DBDIRREADED = 24
|
|||
DBDIRRESTORE = 16384
|
|||
DBDIRTS = 32768
|
|||
DBDIRUNCHANGED = 512
|
|||
DBDIRWARNING = 32
|
|||
DBDUMPMAX = 500
|
|||
DBESCAPE =
|
|||
DBESCESC =
|
|||
DBFLAGDIR =
|
|||
DBFLAGFILE =
|
|||
DBFLAGNONE =
|
|||
DBFLAGSYMLINK =
|
|||
DBFLAGUNKNOWN =
|
|||
DBFORCEDIRBAG = 1
|
|||
DBFORCEDIRBAGALL = 16
|
|||
DBFORCEDIRBAGCOPY = 128
|
|||
DBFORCEDIRNEWER = 8
|
|||
DBFORCEDIRNONE = 0
|
|||
DBFORCEDIROLDER = 4
|
|||
DBFORCEDIRORIGIN = 2
|
|||
DBFORCEDIRORIGINALL = 32
|
|||
DBFORCEDIRORIGINCOPY = 64
|
|||
DBITEMID = 23
|
|||
DBITEMNONE = None
|
|||
DBLINKNONE =
|
|||
DBMDATENONE = 0.0
|
|||
DBNONE = 0
|
|||
DBORIGCRC32 = 204
|
|||
DBORIGFLAG = 201
|
|||
DBORIGLINK = 207
|
|||
DBORIGMDATE = 203
|
|||
DBORIGPATH = 206
|
|||
DBORIGREAD = 205
|
|||
DBORIGSIZE = 202
|
|||
DBPATH = 0
|
|||
DBPATHNONE =
|
|||
DBREADNONE = False
|
|||
DBREADYES = True
|
|||
DBSEP =
|
|||
DBSYMEMULNONE = False
|
|||
DBSYMLINK = 19
|
|||
DBSYMLINKEMUL = 26
|
|||
DBSYNC = 17
|
|||
DBSYNCCOMPARE = 128
|
|||
DBSYNCCONFLICT = 512
|
|||
DBSYNCERRCOMPARE = 64
|
|||
DBSYNCERROR = 111
|
|||
DBSYNCERROTHER = 32
|
|||
DBSYNCERRREAD = 3
|
|||
DBSYNCERRREADBAG = 1
|
|||
DBSYNCERRREADSYNC = 2
|
|||
DBSYNCERRWRITE = 12
|
|||
DBSYNCERRWRITEBAG = 4
|
|||
DBSYNCERRWRITESYNC = 8
|
|||
DBSYNCIGNORED = 256
|
|||
DBSYNCNONE = 0
|
|||
DBSYNCOK = 16
|
|||
IBAG = 100
|
|||
ICRC32 = 4
|
|||
IDB = 300
|
|||
IFLAG = 1
|
|||
ILINK = 7
|
|||
IMDATE = 3
|
|||
IPATH = 6
|
|||
IREAD = 5
|
|||
ISIZE = 2
|
|||
ISYNC = 200
|
|||
LI_CANCEL = 0
|
|||
LI_DESC = 4
|
|||
LI_ERROR = 1
|
|||
LI_FILTERRUNNING = 9
|
|||
LI_FUN2 = 7
|
|||
LI_LENGTH = 11
|
|||
LI_PERCENT = 2
|
|||
LI_PERCENT100 = 3
|
|||
LI_PERCENTGLOBAL = 6
|
|||
LI_PERCENTPART = 5
|
|||
LI_THREAD = 10
|
|||
LI_UPDATEFILTER = 8
|
|||
LOOPN = 10000
|
|||
MDDELTA_DEFAULT =
|
|||
O_ACTION =
|
|||
O_K_DICT =
|
|||
O_K_LIST =
|
|||
O_REPORTFILTER =
|
|||
O_REPORTFORMAT =
|
|||
O_REPORTTYPE =
|
|||
O_S_DICT =
|
|||
O_S_LIST =
|
|||
PYBAG_COLORIZE_DEFAULT =
|
|||
PYBAG_DEBUG_DEFAULT =
|
|||
PYBAG_EMUL_DEFAULT =
|
|||
PYBAG_LOG_DEFAULT =
|
|||
P_BACKUP =
|
|||
P_BACKUPNO =
|
|||
P_BACKUPYES =
|
|||
P_COLORIZE =
|
|||
P_COMPARE =
|
|||
P_COMPARECRC32 =
|
|||
P_COMPARESTAT =
|
|||
P_DEBUG =
|
|||
P_DEFBACKUP =
|
|||
P_DEFCOMPARE =
|
|||
P_DEFIGNORE =
|
|||
P_DEFSELECTDEFAULT =
|
|||
P_DEFSYMLINK =
|
|||
P_EMUL =
|
|||
P_GUI =
|
|||
P_IGNORE =
|
|||
P_IGNORENONE =
|
|||
P_LOGGING =
|
|||
P_MDDELTA =
|
|||
P_OUTFILTER =
|
|||
P_OUTPUT =
|
|||
P_SELECTDEFAULT =
|
|||
P_SELECTDEFAULTNO =
|
|||
P_SELECTDEFAULTYES =
|
|||
P_SHOWTIPS =
|
|||
P_SYMLINK =
|
|||
P_SYMLINKCOPY =
|
|||
P_SYMLINKCOPYNOEMUL =
|
|||
P_SYMLINKIGNORE =
|
|||
P_SYMLINKIGNORENOEMUL =
|
|||
P_SYMLINK_EMUL =
|
|||
P_SYMLINK_IGNORE =
|
|||
P_TIPSNUMBER =
|
|||
P_VERB =
|
|||
P_WRITECOLSATEXIT =
|
|||
REPORTDIR_DEFAULT =
|
|||
REPORTFILTER_DEFAULT =
|
|||
REPORTFORMAT_DEFAULT =
|
|||
REPORTPAGE_DEFAULT =
|
|||
REPORTPATT_DEFAULT =
|
|||
REPORTTYPE_DEFAULT =
|
|||
TSDIRBAG = 1
|
|||
TSDIRNONE = 0
|
|||
TSDIRORIG = 2
|
|||
VERBOSE_DEFAULT =
|
|||
Z_DBFORCE =
|
|||
__package__ = None
|
|||
z_action_choise =
|
|||
z_backupmode =
|
|||
z_compare_choice =
|
|||
z_db_formatlist =
|
|||
z_db_marker =
|
|||
z_db_marker_len = 19
|
|||
z_db_version =
|
|||
z_pble =
|
|||
z_pblmaxlen = 4096
|
|||
z_pbls =
|
|||
z_symlink_choice =
|
|||
Imports: shutil, sys, time, getopt, atexit, ConfigParser, gzip, binascii, traceback, codecs, os, re, cfg, log, prt0, prt1, prt2, prt3, prt4, prt5, dbg, z_u, prt, log_clear, init_encoding, __header__, _usage, __about__, termcolors
|
|||
Start command parser.
|
Test if programm location already initialized.
|
Initialize program environment. Test current program location for initialization. Ask user for initialization if need and initialize if user agree. In initialization time (if user agree) set emulation off. After return it in previous state. Create needed files and folders if it not exist. Read configuration file.
|
Initialize bag in path. Create path if need. Do not change already exists files.
|
Initialize database file in specified path. If not exists then create
DB ==
|
Initialize configuration file in specified path. If not exists then create next configuration file: # PYBAG configuraton file. [root] nextid = 1 ignore = compare = stat symlink = copy colorize = 1 # Subroots sections.
|
Initialize pybagfiles directory in specified path. If not exists then create empty directory "pybagfiles".
|
Translate report option -g into global variables.
|
Read database file pybag.db (gzipped). If errors occurs then setup z_r.e to error message. In DB files placed in next format:
All lines must end with newline.:
All lines must end with newline. Read only DB information. |
Save database to file. If errors occurs hen setup z_r.e to error message. In DB files placed in next format:
For details format see dbread. |
Dump DB row to string. Dump only items from z_db_formatlist. |
Dump DB to string. Dump only items from z_db_formatlist. |
Normalize DB - convert values to right type and past default if absent. If no such index or wrong values or type then create and set to default.
|
Return list of path's parts.
Warning:
Normalize path before splitting. See
|
See splitpaths. Used for DB format paths. |
For DB format paths return parent directory for given path. If no parent return empty string u''. |
Convert path to DB format (separate by DBSEP). Warning:
Path started from root "/" converted wrongly -
"/" character changed to os separator. For example
" |
Top-down directory walker. return in iterate (r,d,f), as python standard os.walk. Note: Default python os.walk some times generate error in mixing encodings in file names ... may be it bug? |
Test file for symlink emulation or real. Return True if symlink, False overwise.
|
Read symbolic link point. Use native function if support or emulate. If filesystem not support link then also emulate it. Emulate file format is: "pybaglink start:xxxxxxxxxx:pybaglink end". File encoding is "utf_8".
|
Save symbolic link point. Use native function if support or emulate. If filesystem not support link then also emulate it. Before create new link you must remove previous. Emulate file format is: "pybaglink start:xxxxxxxxxx:pybaglink end". File encoding is "utf_8".
|
Delete directory recursively. Delete everything reachable from the directory named in 'path', (do not follow for symbolic link). Warning: This is dangerous! For example, if path == '/home', it could delete all your home files. !!! ROOT FOLDERS ('/' and 'C:') CAN NOT BE DELETED THIS FUNCTION!!! If you want delete root folder you must delete it manualy. |
Copy files tree from "src" to "dst". "dst" must be a directory. If "symlinks" True then also copy symlinks (default False). If symlinks not supported then they emulated. If "dst" not exists then create it. From copying exluded items equal "exclude" list. |
Validate paths.
|
Calculate CRC32 for given file. Return 0 for other situation (directory, link, absent). |
Walk throw bagpath files from pybagfiles and syncpath for original files.
Warning: path must be in absolute normalized format and must exists. Usually this function get arguments that returned by validatepaths. |
Translate option in command. Get from "cmd" list "cmd.x" where x - is "opt". Get value from dictionary O_X_DICT[O_X_LIST[cmd.x[-1]]]. If no "cmd.x" then return O_X_DICT[O_X_LIST[0]]. If not supported option then return empty string ''.
|
Unknown command. Print message about unknown command. |
Show info about bag files.
|
Output comparison report from database db in console. Filter output |
Perform changes into db[DBDIR] to specified action.
|
Synchronize files. Algorithm:
|
Read DB, files.
|
Compare DB. Return tuple of number modified items.
Warning: All paths (BAG, Origin) must be filled. And DB must be normalized. |
Syncronize DB. Return tuple of modified and errored items. |
Clear DB. Remove from DB unused record (successfully deleted and ignored items). |
Debug function. Test functions. |
|
|||
climenuMenu for display in command line version in synchronization.
|
climenuhelpMenu help for display in command line version in synchronization.
|
pagemenu
|
O_ACTION
|
O_K_DICT
|
O_K_LIST
|
O_REPORTFILTER
|
O_REPORTFORMAT
|
Z_DBFORCE
|
z_action_choise
|
z_db_formatlist
|
z_symlink_choice
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Fri Sep 13 23:40:40 2019 | http://epydoc.sourceforge.net |