j.tools.text
- /opt/jumpscale7/lib/JumpScale/core/system/text.py
- Properties
- machinetext2val
- dealWithQuote
- lstrip
- pythonObjToStr1line
- wrap
- prefix_remove_withtrailing
- prefix
- toSafePath
- strip
- isNumeric
- addTimeHR
- machinetext2str
- hrd2machinetext
- getDict
- getMacroCandidates
- isInt
- prefix_remove
- toAscii
- addCmd
- pythonObjToStr
- dealWithList
- toStr
- getBool
- getFloat
- toUnicode
- eval
- ask
- addVal
- isFloat
- replaceQuotes
- str2var
- getInt
- getList
Methods
def addCmd
arguments
def addTimeHR
arguments
def addVal
arguments
- out
- name
- val
- addtimehr = False
def ask
arguments
- content
- name
- args = {}
- ask = True
look for @ASK statements in text, where found replace with input from user
syntax for ask is:
@ASK name:aname type:str descr:adescr default:adefault regex:aregex retry:10
minValue:10 maxValue:20 dropdownvals:1,2,3
descr, default & regex can be between '' if spaces inside
types are: str,float,int,bool,dropdown,multiline
the multiline will open joe as editor
retry means will keep on retrying x times until ask is done properly
dropdownvals is comma separated list of values to ask for when type dropdown
@ASK can be at any position in the text
def dealWithList
arguments
look for [something,2] the comma needs to be converted to \k
def dealWithQuote
arguments
look for 'something,else' the comma needs to be converted to \k
def eval
arguments
look for \{\{\}\} in code and evaluate as python result is converted back to str
def getBool
arguments
def getDict
arguments
- text
- ttype
- deserialize = False
keys are always treated as string
@type can be int,bool or float (otherwise its always str)
def getFloat
arguments
def getInt
arguments
def getList
arguments
- text
- ttype
- deserialize = False
@type can be int,bool or float (otherwise its always str)
def getMacroCandidates
arguments
look for \{\{\}\} return as list
def hrd2machinetext
arguments
'something ' removes ''
all spaces & commas & : inside ' ' are converted
SPACE -> \S
" -> \Q
, -> \K
: -> \D
\n -> \N
def isFloat
arguments
def isInt
arguments
def isNumeric
arguments
def lstrip
arguments
remove all spaces at beginning & end of line when relevant
def machinetext2str
arguments
do reverse of:
SPACE -> \S
" -> \Q
, -> \K
: -> \D
-> \N
def machinetext2val
arguments
do reverse of:
SPACE -> \S
" -> \Q
, -> \K
: -> \D
\n -> return
def prefix
arguments
def prefix_remove
arguments
- prefix
- txt
- onlyPrefix = False
@param onlyPrefix if True means only when prefix found will be returned, rest discarded
def prefix_remove_withtrailing
arguments
- prefix
- txt
- onlyPrefix = False
there can be chars for prefix (e.g. '< :*: aline' and this function looking for :*: would
still work and ignore '< ')
@param onlyPrefix if True means only when prefix found will be returned, rest discarded
def pythonObjToStr
arguments
- obj
- multiline = True
- canBeDict = True
- partial = False
try to convert a python object to string representation works for None, bool, integer,
float, dict, list
def pythonObjToStr1line
arguments
def replaceQuotes
arguments
def str2var
arguments
convert list, dict of strings
or convert 1 string to python objects
def strip
arguments
def toAscii
arguments
def toSafePath
arguments
process string so it can be used in a path on windows or linux
def toStr
arguments
def toUnicode
arguments
def wrap
arguments