ez


Nameez JSON
Version 3.7.2 PyPI version JSON
download
home_pagehttps://pypi.python.org/pypi/ez
Summaryeasy stuff
upload_time2018-03-21 23:42:58
maintainer
docs_urlNone
authorJerry Zhu
requires_python
licenseGPLv3+
keywords shell
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            This module is for easy interaction with linux, Mac OS X, Windows shell.
=============================================
jerryzhujian9_at_gmail.com
Tested under python 2.7
To see your python version
in terminal: python -V
or in python: import sys; print (sys.version)
=============================================
Install:
https://pypi.python.org/pypi/ez
pip install ez
no dependencies

Almost all commands support the usage of '~', '..', '.', '?', '*' in path (ls,fls only support regular expression).
Symbolic link itself is the target of file operations; the actual file should be safe.

see also pyg.py
debug(1/0)
    # 0 = everything will be actually executed
    # 1 = simulate operations of cp, mv, execute; other commands will be actually performed.
          will print out simulated commands, useful for debugging and for counting files when necessary.
error(msg)

readx(path, sheet=0, r=[1,], c=None)  # Read xlsx, xls file into a list
savex(path, data, header=None, delimiter=",", sheet_name='Sheet1') # Write a list of list to a xlsx (xlsxwriter), xls(xlwt), csv file

fullpath(path) fp()
pwd() or cwd()  # Returns current working director.
csd() # Returns full path of current script directory, i.e. the directory where the running script is. 
csf() # Returns current script name without ext.
parentdir(path) pr() # Returns the parent directory of a path.
joinpath(path1[, path2[, ...]])   jp() # Returns the joined path. Supports vectorization.
splitpath(path) sp() # Returns a list of path elements: [path, file, ext]. Supports vectorization.
cd(path)    # Changes to a new working directory.
stepfolder(-1)

trim(string,how[,chars])
join(sep,string1,string2), join(sep,array) # Glues together strings with sep. Supports vectorization.
sort(array)
replace(theList,theItem,replacement), remove(theList,theItem)

ls([path[, regex]], full=True, dotfile=False)    # Returns a list of all (including hidden) files with their full paths in path, filtered by regular expression.
lsd([path[, regex]], full=False, dotfolder=False)
fls([path[, regex, dotf=False]])   # Returns a list of files with their full paths in flattened path (i.e. walk each subdirectory).
# the filter only works for short file name not for full file name, i.e. the file name itself not its full path
# regular expression is case-sensitive
# usage: ls(); ls(cwd()); ls(cwd(), "\.py$")

mkdir("path/to/a/directory")    # Makes a directory (also any one of the "path", "to", "a" directories if not exits).
rn(old, new) # Renames old to new.
exists(path)    # Returns the existence of path (0 or 1).
rm(path)    # Deletes a file or folder. Supports wildcards, vectorization.
cp(source, destination)  # Copies source file(s) or folder to destination. Supports wildcards, vectorization.
mv(source, destination)  # Moves source file(s) or folder to destination. Supports wildcards, vectorization.

sprintf(formatString, *args, **kwargs)
evaluate(exp)
# Executes a shell command
# execute/esp/espR no capture output (subprocess.call), execute1 discard--not return--captured, execute2 captures output (subprocess.Popen)
execute, execute1, execute2    
esp, esp1, esp2 # execute sprintf shell commands
espR, espR1, espR2 # execute sprintf R codes
with nooutput():
    print 'this is will not be printed in stdout'
pprint(text,color='green') # color print; ppprint() # "pretty-print" arbitrary Python data structures
beep()  # Beeps to notify user.
which(name) # Prints where a module is and in which module a function is. which('python') returns which python is being used.
help(name)/doc(name) # name is a string, Prints the doc string of a module/class/function
    when write a module, add:
    __doc__ = three double quotes blabla three double quotes         <-----this is module's docstring, use explicit

    when write a function/class:
    def function(arg):
        three double quotes Returns, blabla three double quotes      <-----this is function's doctoring, use implicit
        return sth
ver(package_name) version(package_name), see a package's version.  package_name could be 'python'
whos(name),whos() list imported functions/packages

logon(file="log.txt", mode='a', status=True, timestamp=True), logoff()

tree([path[, forest=True]) # Prints a directory tree structure. 
    forest=True (default) prints only folders, i.e., print less to show the big forest
    forest=False prints files plus folders

[starts, ends] = regexp(string, pattern); regexp(string, pattern, method='split/match'), regexpi
regexprep(string, pattern, replace, count=0), regexprepi

iff(expression, result1, result2), ifelse()
clear(module, recursive=False)

num(string)
isempty(s)
Randomize(x), randomize(x) # Sets a randomization seed.
RandomizeArray(list=[])   randomizearray(list=[])  # Shuffles a list in place.
Random(a,b) random(a,b) # Returns a random integer N such that a <= N <= b.
RandomChoice(seq), randomchoice(seq) # Returns a random element from sequence
Permute(iterable=[]) permute(iterable=[]) # Returns permutations in a list

unique(seq), union(seq1,seq2), intersect(seq1,seq2), setdiff(seq1,seq2) in original order
seq could be a list
    note: setdiff(seq1,seq2) may not be equal to setdiff(seq2,seq1)
            >>> unique('abracadaba')
            ['a', 'b', 'r', 'c', 'd']
            >>> unique('simsalabim')
            ['s', 'i', 'm', 'a', 'l', 'b']
            >>>
            >>> setdiff('abracadaba','simsalabim')
            ['r', 'c', 'd']
            >>> setdiff('simsalabim','abracadaba')
            ['s', 'i', 'm', 'l']
duplicate(seq) # returns a list of duplicated elements in original order
    # e.g.
    # a = [1,5,2,3,2,1,5,6,5,5,5]
    # duplicate(a) # yields [2, 1, 5]

JDict() # Jerry's dictionary, customized ordered dictionary class with convient attributes and methods, see help(JDict)
Moment(timezone)    # Generates the current datetime in specified timezone, or local naive datetime if omitted.

SetClip(content), setclip(content)   # Copy/Write something to current clipboard
content = GetClip(), content = getclip()   # Read out content from current clipboard and assign to a variable

lines(path='.', pattern='\.py$|.ini$|\.c$|\.h$|\.m$', recursive=True) # Counts lines of codes, counting empty lines as well.
keygen(length=8, complexity=3)  # generate a random key
hashes(filename): # Calculate/Print a file's md5 32; sha1 32; can handle big files in a memory efficient way
pinyin()
hanzifreq()
pipe usage: # http://0101.github.io/pipetools/doc/
    # result = [1,2,3,0] > ez.pipe | len | str
    # countdown = ez.pipe|(range, -1)|reversed|ez.pipetools.foreach('{0}...')|' '.join|'{0} boom'; countdown(5)





To avoid typing email password each time, place a file named pygmailconfig.py with
EMAIL = 'someone@gmail.com'
PASSWORD = 'abcdefghik'
or better pygmailconfig.pyc
in the site-packages/ez folder, check with ez.which('ez')
The functions will no longer need email/password and become like this
Mail(to, subject, body, attach=None), AddEvent(event), Sheet(fileName)

Mail([EMAIL, PASSWORD, ] to, subject, body, attachment=None, bcc=None, cc=None, reply_to=None)
        to/bcc/cc: ['a@a.com','b@b.com'] or 'a@a.com, b@b.com'
        reply_to: 'a@a.com'
        attachment: 'file_in_working_dir.txt' or ['a.txt','b.py','c.pdf']
AddEvent([EMAIL, PASSWORD, ] event)     on DATE at TIME for DURATION in PLACE

Sheet([EMAIL, PASSWORD, ] fileName)
    returns a sheet object representing "Sheet 1"

    your google account doesn't have to the owner of this sheet, as long as you can edit it.
    but you need to initialize/create this sheet and maybe the header by hand to begin with
    the header could have spaces, ? etc, and when they are used as the keywords of dictionary, they are all converted to lowercase and all illegal characters are removed e.g. Delayed Test_date?  --> delayedtestdate

    fileName should be unique, can have spaces


GetRows(query=None, order_by=None,
        reverse=None, filter_func=None)
    :param query:
        A string structured query on the full text in the worksheet.
          [columnName][binaryOperator][value]
          Supported binaryOperators are:
          - (), for overriding order of operations
          - = or ==, for strict equality
          - <> or !=, for strict inequality
          - and or &&, for boolean and
          - or or ||, for boolean or.
    :param order_by:
        A string which specifies what column to use in ordering the
        entries in the feed. By position (the default): 'position' returns
        rows in the order in which they appear in the GUI. Row 1, then
        row 2, then row 3, and so on. By column:
        'column:columnName' sorts rows in ascending order based on the
        values in the column with the given columnName, where
        columnName is the value in the header row for that column.
    :param reverse:
        A string which specifies whether to sort in descending or ascending
        order.Reverses default sort order: 'true' results in a descending
        sort; 'false' (the default) results in an ascending sort.
    :param filter_func:
        A lambda function which applied to each row, Gets a row dict as
        argument and returns True or False. Used for filtering rows in
        memory (as opposed to query which filters on the service side).
    :return:
        A list of row dictionaries.


UpdateRow(row_data):
    Update Row (By ID).

    Only the fields supplied will be updated.
    :param row_data:
        A dictionary containing row data. The row will be updated according
        to the value in the ID_FIELD.
    :return:
        The updated row.


UpdateRowByIndex(index, row_data):
    Update Row By Index

    :param index:
        An integer designating the index of a row to update (zero based).
        Index is relative to the returned result set, not to the original
        spreadseet.
    :param row_data:
        A dictionary containing row data.
    :return:
        The updated row.


InsertRow(row_data):
    Append Row at the end

    :param row_data:
        A dictionary containing row data.
    :return:
        A row dictionary for the inserted row.


DeleteRow(row):
    Delete Row (By ID).

    Requires that the given row dictionary contains an ID_FIELD.
    :param row:
        A row dictionary to delete.


DeleteRowByIndex(index):
    Delete Row By Index

    :param index:
        A row index. Index is relative to the returned result set, not to
        the original spreadsheet.


DeleteAllRows():
    Delete All Rows

            

Raw data

            {
    "maintainer": "", 
    "docs_url": null, 
    "requires_python": "", 
    "maintainer_email": "", 
    "cheesecake_code_kwalitee_id": null, 
    "keywords": "shell", 
    "upload_time": "2018-03-21 23:42:58", 
    "author": "Jerry Zhu", 
    "home_page": "https://pypi.python.org/pypi/ez", 
    "download_url": "https://pypi.python.org/packages/44/b8/eba11faf3cba7a4239a1c94e04f347cf7c543471b8ddfff9627fbb02c223/ez-3.7.2.tar.gz", 
    "platform": "", 
    "version": "3.7.2", 
    "cheesecake_documentation_id": null, 
    "description": "This module is for easy interaction with linux, Mac OS X, Windows shell.\n=============================================\njerryzhujian9_at_gmail.com\nTested under python 2.7\nTo see your python version\nin terminal: python -V\nor in python: import sys; print (sys.version)\n=============================================\nInstall:\nhttps://pypi.python.org/pypi/ez\npip install ez\nno dependencies\n\nAlmost all commands support the usage of '~', '..', '.', '?', '*' in path (ls,fls only support regular expression).\nSymbolic link itself is the target of file operations; the actual file should be safe.\n\nsee also pyg.py\ndebug(1/0)\n    # 0 = everything will be actually executed\n    # 1 = simulate operations of cp, mv, execute; other commands will be actually performed.\n          will print out simulated commands, useful for debugging and for counting files when necessary.\nerror(msg)\n\nreadx(path, sheet=0, r=[1,], c=None)  # Read xlsx, xls file into a list\nsavex(path, data, header=None, delimiter=\",\", sheet_name='Sheet1') # Write a list of list to a xlsx (xlsxwriter), xls(xlwt), csv file\n\nfullpath(path) fp()\npwd() or cwd()  # Returns current working director.\ncsd() # Returns full path of current script directory, i.e. the directory where the running script is. \ncsf() # Returns current script name without ext.\nparentdir(path) pr() # Returns the parent directory of a path.\njoinpath(path1[, path2[, ...]])   jp() # Returns the joined path. Supports vectorization.\nsplitpath(path) sp() # Returns a list of path elements: [path, file, ext]. Supports vectorization.\ncd(path)    # Changes to a new working directory.\nstepfolder(-1)\n\ntrim(string,how[,chars])\njoin(sep,string1,string2), join(sep,array) # Glues together strings with sep. Supports vectorization.\nsort(array)\nreplace(theList,theItem,replacement), remove(theList,theItem)\n\nls([path[, regex]], full=True, dotfile=False)    # Returns a list of all (including hidden) files with their full paths in path, filtered by regular expression.\nlsd([path[, regex]], full=False, dotfolder=False)\nfls([path[, regex, dotf=False]])   # Returns a list of files with their full paths in flattened path (i.e. walk each subdirectory).\n# the filter only works for short file name not for full file name, i.e. the file name itself not its full path\n# regular expression is case-sensitive\n# usage: ls(); ls(cwd()); ls(cwd(), \"\\.py$\")\n\nmkdir(\"path/to/a/directory\")    # Makes a directory (also any one of the \"path\", \"to\", \"a\" directories if not exits).\nrn(old, new) # Renames old to new.\nexists(path)    # Returns the existence of path (0 or 1).\nrm(path)    # Deletes a file or folder. Supports wildcards, vectorization.\ncp(source, destination)  # Copies source file(s) or folder to destination. Supports wildcards, vectorization.\nmv(source, destination)  # Moves source file(s) or folder to destination. Supports wildcards, vectorization.\n\nsprintf(formatString, *args, **kwargs)\nevaluate(exp)\n# Executes a shell command\n# execute/esp/espR no capture output (subprocess.call), execute1 discard--not return--captured, execute2 captures output (subprocess.Popen)\nexecute, execute1, execute2    \nesp, esp1, esp2 # execute sprintf shell commands\nespR, espR1, espR2 # execute sprintf R codes\nwith nooutput():\n    print 'this is will not be printed in stdout'\npprint(text,color='green') # color print; ppprint() # \"pretty-print\" arbitrary Python data structures\nbeep()  # Beeps to notify user.\nwhich(name) # Prints where a module is and in which module a function is. which('python') returns which python is being used.\nhelp(name)/doc(name) # name is a string, Prints the doc string of a module/class/function\n    when write a module, add:\n    __doc__ = three double quotes blabla three double quotes         <-----this is module's docstring, use explicit\n\n    when write a function/class:\n    def function(arg):\n        three double quotes Returns, blabla three double quotes      <-----this is function's doctoring, use implicit\n        return sth\nver(package_name) version(package_name), see a package's version.  package_name could be 'python'\nwhos(name),whos() list imported functions/packages\n\nlogon(file=\"log.txt\", mode='a', status=True, timestamp=True), logoff()\n\ntree([path[, forest=True]) # Prints a directory tree structure. \n    forest=True (default) prints only folders, i.e., print less to show the big forest\n    forest=False prints files plus folders\n\n[starts, ends] = regexp(string, pattern); regexp(string, pattern, method='split/match'), regexpi\nregexprep(string, pattern, replace, count=0), regexprepi\n\niff(expression, result1, result2), ifelse()\nclear(module, recursive=False)\n\nnum(string)\nisempty(s)\nRandomize(x), randomize(x) # Sets a randomization seed.\nRandomizeArray(list=[])   randomizearray(list=[])  # Shuffles a list in place.\nRandom(a,b) random(a,b) # Returns a random integer N such that a <= N <= b.\nRandomChoice(seq), randomchoice(seq) # Returns a random element from sequence\nPermute(iterable=[]) permute(iterable=[]) # Returns permutations in a list\n\nunique(seq), union(seq1,seq2), intersect(seq1,seq2), setdiff(seq1,seq2) in original order\nseq could be a list\n    note: setdiff(seq1,seq2) may not be equal to setdiff(seq2,seq1)\n            >>> unique('abracadaba')\n            ['a', 'b', 'r', 'c', 'd']\n            >>> unique('simsalabim')\n            ['s', 'i', 'm', 'a', 'l', 'b']\n            >>>\n            >>> setdiff('abracadaba','simsalabim')\n            ['r', 'c', 'd']\n            >>> setdiff('simsalabim','abracadaba')\n            ['s', 'i', 'm', 'l']\nduplicate(seq) # returns a list of duplicated elements in original order\n    # e.g.\n    # a = [1,5,2,3,2,1,5,6,5,5,5]\n    # duplicate(a) # yields [2, 1, 5]\n\nJDict() # Jerry's dictionary, customized ordered dictionary class with convient attributes and methods, see help(JDict)\nMoment(timezone)    # Generates the current datetime in specified timezone, or local naive datetime if omitted.\n\nSetClip(content), setclip(content)   # Copy/Write something to current clipboard\ncontent = GetClip(), content = getclip()   # Read out content from current clipboard and assign to a variable\n\nlines(path='.', pattern='\\.py$|.ini$|\\.c$|\\.h$|\\.m$', recursive=True) # Counts lines of codes, counting empty lines as well.\nkeygen(length=8, complexity=3)  # generate a random key\nhashes(filename): # Calculate/Print a file's md5 32; sha1 32; can handle big files in a memory efficient way\npinyin()\nhanzifreq()\npipe usage: # http://0101.github.io/pipetools/doc/\n    # result = [1,2,3,0] > ez.pipe | len | str\n    # countdown = ez.pipe|(range, -1)|reversed|ez.pipetools.foreach('{0}...')|' '.join|'{0} boom'; countdown(5)\n\n\n\n\n\nTo avoid typing email password each time, place a file named pygmailconfig.py with\nEMAIL = 'someone@gmail.com'\nPASSWORD = 'abcdefghik'\nor better pygmailconfig.pyc\nin the site-packages/ez folder, check with ez.which('ez')\nThe functions will no longer need email/password and become like this\nMail(to, subject, body, attach=None), AddEvent(event), Sheet(fileName)\n\nMail([EMAIL, PASSWORD, ] to, subject, body, attachment=None, bcc=None, cc=None, reply_to=None)\n        to/bcc/cc: ['a@a.com','b@b.com'] or 'a@a.com, b@b.com'\n        reply_to: 'a@a.com'\n        attachment: 'file_in_working_dir.txt' or ['a.txt','b.py','c.pdf']\nAddEvent([EMAIL, PASSWORD, ] event)     on DATE at TIME for DURATION in PLACE\n\nSheet([EMAIL, PASSWORD, ] fileName)\n    returns a sheet object representing \"Sheet 1\"\n\n    your google account doesn't have to the owner of this sheet, as long as you can edit it.\n    but you need to initialize/create this sheet and maybe the header by hand to begin with\n    the header could have spaces, ? etc, and when they are used as the keywords of dictionary, they are all converted to lowercase and all illegal characters are removed e.g. Delayed Test_date?  --> delayedtestdate\n\n    fileName should be unique, can have spaces\n\n\nGetRows(query=None, order_by=None,\n        reverse=None, filter_func=None)\n    :param query:\n        A string structured query on the full text in the worksheet.\n          [columnName][binaryOperator][value]\n          Supported binaryOperators are:\n          - (), for overriding order of operations\n          - = or ==, for strict equality\n          - <> or !=, for strict inequality\n          - and or &&, for boolean and\n          - or or ||, for boolean or.\n    :param order_by:\n        A string which specifies what column to use in ordering the\n        entries in the feed. By position (the default): 'position' returns\n        rows in the order in which they appear in the GUI. Row 1, then\n        row 2, then row 3, and so on. By column:\n        'column:columnName' sorts rows in ascending order based on the\n        values in the column with the given columnName, where\n        columnName is the value in the header row for that column.\n    :param reverse:\n        A string which specifies whether to sort in descending or ascending\n        order.Reverses default sort order: 'true' results in a descending\n        sort; 'false' (the default) results in an ascending sort.\n    :param filter_func:\n        A lambda function which applied to each row, Gets a row dict as\n        argument and returns True or False. Used for filtering rows in\n        memory (as opposed to query which filters on the service side).\n    :return:\n        A list of row dictionaries.\n\n\nUpdateRow(row_data):\n    Update Row (By ID).\n\n    Only the fields supplied will be updated.\n    :param row_data:\n        A dictionary containing row data. The row will be updated according\n        to the value in the ID_FIELD.\n    :return:\n        The updated row.\n\n\nUpdateRowByIndex(index, row_data):\n    Update Row By Index\n\n    :param index:\n        An integer designating the index of a row to update (zero based).\n        Index is relative to the returned result set, not to the original\n        spreadseet.\n    :param row_data:\n        A dictionary containing row data.\n    :return:\n        The updated row.\n\n\nInsertRow(row_data):\n    Append Row at the end\n\n    :param row_data:\n        A dictionary containing row data.\n    :return:\n        A row dictionary for the inserted row.\n\n\nDeleteRow(row):\n    Delete Row (By ID).\n\n    Requires that the given row dictionary contains an ID_FIELD.\n    :param row:\n        A row dictionary to delete.\n\n\nDeleteRowByIndex(index):\n    Delete Row By Index\n\n    :param index:\n        A row index. Index is relative to the returned result set, not to\n        the original spreadsheet.\n\n\nDeleteAllRows():\n    Delete All Rows\n", 
    "lcname": "ez", 
    "bugtrack_url": null, 
    "github": false, 
    "name": "ez", 
    "license": "GPLv3+", 
    "summary": "easy stuff", 
    "split_keywords": [
        "shell"
    ], 
    "author_email": "jerryzhujian9@gmail.com", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2018-03-21T23:42:58", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/44/b8/eba11faf3cba7a4239a1c94e04f347cf7c543471b8ddfff9627fbb02c223/ez-3.7.2.tar.gz", 
            "md5_digest": "b3e752f4680abc8f6568af45845c3416", 
            "downloads": 0, 
            "filename": "ez-3.7.2.tar.gz", 
            "packagetype": "sdist", 
            "path": "44/b8/eba11faf3cba7a4239a1c94e04f347cf7c543471b8ddfff9627fbb02c223/ez-3.7.2.tar.gz", 
            "size": 948578
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}