Python string.joinfields() Examples

The following are 23 code examples for showing how to use string.joinfields(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module string , or try the search function .

Example 1
Project: conary   Author: sassoftware   File: __init__.py    License: Apache License 2.0 6 votes vote down vote up
def do_mailstack(self, arg):
        tolist = arg.split()
        subject = '[Conary Stacktrace]'
        if 'stack' in self.__dict__:
            # when we're saving we always 
            # start from the top
            frame = self.stack[-1][0]
        else:
            frame = sys._getframe(1)
            while frame.f_globals['__name__'] in ('epdb', 'pdb', 'bdb', 'cmd'):
                frame = frame.f_back
        sender = os.environ['USER']
        host = socket.getfqdn()
        extracontent = None
        if self._tb:
            lines = traceback.format_exception(self._exc_type, self._exc_msg, 
                                               self._tb)
            extracontent = string.joinfields(lines, "")
        epdb_stackutil.mailStack(frame, tolist, sender + '@' + host, subject,
                            extracontent)
        print "Mailed stack to %s" % tolist 
Example 2
Project: epdb   Author: sassoftware   File: __init__.py    License: MIT License 6 votes vote down vote up
def do_mailstack(self, arg):
        tolist = arg.split()
        subject = '[Conary Stacktrace]'
        if 'stack' in self.__dict__:
            # when we're saving we always start from the top
            frame = self.stack[-1][0]
        else:
            frame = sys._getframe(1)
            while frame.f_globals['__name__'] in ('epdb', 'pdb', 'bdb', 'cmd'):
                frame = frame.f_back
        sender = os.environ['USER']
        host = socket.getfqdn()
        extracontent = None
        if self._tb:
            lines = traceback.format_exception(self._exc_type, self._exc_msg,
                                               self._tb)
            extracontent = string.joinfields(lines, "")
        epdb_stackutil.mailStack(frame, tolist, sender + '@' + host, subject,
                                 extracontent)
        print("Mailed stack to %s" % tolist) 
Example 3
Project: razzy-spinner   Author: rafasashi   File: wordnet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __str__(self):
	"""Return a human-readable representation.
	
	>>> str(N['dog'][0].synset)
	'{noun: dog, domestic dog, Canis familiaris}'
	"""
	return "{" + self.pos + ": " + string.joinfields(map(lambda sense:sense.form, self.getSenses()), ", ") + "}" 
Example 4
Project: razzy-spinner   Author: rafasashi   File: wordnet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __str__(self):
	"""Return a human-readable representation.
	
	>>> str(N['dog'][0].synset)
	'{noun: dog, domestic dog, Canis familiaris}'
	"""
	return "{" + self.pos + ": " + string.joinfields(map(lambda sense:sense.form, self.getSenses()), ", ") + "}" 
Example 5
Project: ironpython2   Author: IronLanguages   File: dbrecio.py    License: Apache License 2.0 5 votes vote down vote up
def writelines(self, list):
        self.write(string.joinfields(list, '')) 
Example 6
Project: BinderFilter   Author: dxwu   File: dbrecio.py    License: MIT License 5 votes vote down vote up
def writelines(self, list):
        self.write(string.joinfields(list, '')) 
Example 7
Project: Computable   Author: ktraunmueller   File: dbrecio.py    License: MIT License 5 votes vote down vote up
def writelines(self, list):
        self.write(string.joinfields(list, '')) 
Example 8
Project: oss-ftp   Author: aliyun   File: dbrecio.py    License: MIT License 5 votes vote down vote up
def writelines(self, list):
        self.write(string.joinfields(list, '')) 
Example 9
Project: mxnet-lambda   Author: awslabs   File: PSDraw.py    License: Apache License 2.0 5 votes vote down vote up
def text(self, xy, text):
        text = string.joinfields(string.splitfields(text, "("), "\\(")
        text = string.joinfields(string.splitfields(text, ")"), "\\)")
        xy = xy + (text,)
        self.fp.write("%d %d M (%s) S\n" % xy) 
Example 10
Project: qpid-python   Author: apache   File: codec010.py    License: Apache License 2.0 5 votes vote down vote up
def write_map(self, m):
    sc = StringCodec()
    if m is not None:
      sc.write_uint32(len(m))
      sc.write(string.joinfields(map(self._write_map_elem, m.keys(), m.values()), ""))
    self.write_vbin32(sc.encoded) 
Example 11
Project: Splunking-Crime   Author: nccgroup   File: dbrecio.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def writelines(self, list):
        self.write(string.joinfields(list, '')) 
Example 12
Project: medicare-demo   Author: ofermend   File: javapath.py    License: Apache License 2.0 5 votes vote down vote up
def normpath(path):
    """Normalize path, eliminating double slashes, etc."""
    sep = os.sep
    if sep == '\\':
        path = path.replace("/", sep)
    curdir = os.curdir
    pardir = os.pardir
    import string
    # Treat initial slashes specially
    slashes = ''
    while path[:1] == sep:
        slashes = slashes + sep
        path = path[1:]
    comps = string.splitfields(path, sep)
    i = 0
    while i < len(comps):
        if comps[i] == curdir:
            del comps[i]
            while i < len(comps) and comps[i] == '':
                del comps[i]
        elif comps[i] == pardir and i > 0 and comps[i-1] not in ('', pardir):
            del comps[i-1:i+1]
            i = i-1
        elif comps[i] == '' and i > 0 and comps[i-1] <> '':
            del comps[i]
        else:
            i = i+1
    # If the path is now empty, substitute '.'
    if not comps and not slashes:
        comps.append(curdir)
    return slashes + string.joinfields(comps, sep) 
Example 13
Project: CNCGToolKit   Author: cineuse   File: PSDraw.py    License: MIT License 5 votes vote down vote up
def text(self, xy, text):
        text = string.joinfields(string.splitfields(text, "("), "\\(")
        text = string.joinfields(string.splitfields(text, ")"), "\\)")
        xy = xy + (text,)
        self.fp.write("%d %d M (%s) S\n" % xy) 
Example 14
Project: conary   Author: sassoftware   File: epdb_stackutil.py    License: Apache License 2.0 5 votes vote down vote up
def printTraceBack(tb=None, output=sys.stderr, exc_type=None, exc_msg=None):
    if isinstance(output, str):
        output = open(output, 'w')

    exc_info = sys.exc_info()
    if tb is None:
        tb = exc_info[2]

    if exc_type is None:
        exc_type = exc_info[0]

    if exc_msg is None:
        exc_msg = exc_info[1]

    if exc_type is not None:
        output.write('Exception: ')
        exc_info = '\n'.join(traceback.format_exception_only(exc_type, exc_msg))
        output.write(exc_info)
        output.write('\n\n')

    lines = traceback.format_exception(exc_type, exc_msg, tb)
    output.write(string.joinfields(lines, ""))

    while tb:
        _printFrame(tb.tb_frame, output=output)
        tb = tb.tb_next 
Example 15
Project: conary   Author: sassoftware   File: stackutil.py    License: Apache License 2.0 5 votes vote down vote up
def printTraceBack(tb=None, output=sys.stderr, exc_type=None, exc_msg=None):
    if isinstance(output, str):
        output = open(output, 'w')

    exc_info = sys.exc_info()
    if tb is None:
        tb = exc_info[2]

    if exc_type is None:
        exc_type = exc_info[0]

    if exc_msg is None:
        exc_msg = exc_info[1]

    if exc_type is not None:
        output.write('Exception: ')
        exc_info = '\n'.join(traceback.format_exception_only(exc_type, exc_msg))
        output.write(exc_info)
        output.write('\n\n')

    lines = traceback.format_exception(exc_type, exc_msg, tb)
    output.write(string.joinfields(lines, ""))

    while tb:
        _printFrame(tb.tb_frame, output=output)
        tb = tb.tb_next 
Example 16
Project: conary   Author: sassoftware   File: action.py    License: Apache License 2.0 5 votes vote down vote up
def genExcepthook(self):
    def excepthook(type, exc_msg, tb):
        cfg = self.recipe.cfg
        sys.excepthook = sys.__excepthook__
        if cfg.debugRecipeExceptions:
            lines = traceback.format_exception(type, exc_msg, tb)
            print string.joinfields(lines, "")
        if self.linenum is not None:
            prefix = "%s:%s:" % (self.file, self.linenum)
            prefix_len = len(prefix)
            if str(exc_msg)[:prefix_len] != prefix:
                exc_message = "%s:%s: %s: %s" % (self.file, self.linenum,
                                              type.__name__, exc_msg)
            print exc_message

        if self.recipe.buildinfo:
            try:
                buildinfo = self.recipe.buildinfo
                buildinfo.error = exc_message
                buildinfo.file = self.file
                buildinfo.lastline = self.linenum
                buildinfo.stop()
            except:
                log.warning("could not write out to buildinfo")

        if cfg.debugRecipeExceptions and self.recipe.isatty():
            debugger.post_mortem(tb, type, exc_msg)
        else:
            sys.exit(1)
    return excepthook 
Example 17
Project: epdb   Author: sassoftware   File: epdb_stackutil.py    License: MIT License 5 votes vote down vote up
def printTraceBack(tb=None, output=sys.stderr, exc_type=None, exc_msg=None):
    if isinstance(output, str):
        output = open(output, 'w')

    exc_info = sys.exc_info()
    if tb is None:
        tb = exc_info[2]

    if exc_type is None:
        exc_type = exc_info[0]

    if exc_msg is None:
        exc_msg = exc_info[1]

    if exc_type is not None:
        output.write('Exception: ')
        exc_info = '\n'.join(traceback.format_exception_only(
            exc_type, exc_msg))
        output.write(exc_info)
        output.write('\n\n')

    lines = traceback.format_exception(exc_type, exc_msg, tb)
    output.write(string.joinfields(lines, ""))

    while tb:
        _printFrame(tb.tb_frame, output=output)
        tb = tb.tb_next 
Example 18
Project: CTFCrackTools-V2   Author: Acmesec   File: javapath.py    License: GNU General Public License v3.0 5 votes vote down vote up
def normpath(path):
    """Normalize path, eliminating double slashes, etc."""
    sep = os.sep
    if sep == '\\':
        path = path.replace("/", sep)
    curdir = os.curdir
    pardir = os.pardir
    import string
    # Treat initial slashes specially
    slashes = ''
    while path[:1] == sep:
        slashes = slashes + sep
        path = path[1:]
    comps = string.splitfields(path, sep)
    i = 0
    while i < len(comps):
        if comps[i] == curdir:
            del comps[i]
            while i < len(comps) and comps[i] == '':
                del comps[i]
        elif comps[i] == pardir and i > 0 and comps[i-1] not in ('', pardir):
            del comps[i-1:i+1]
            i = i-1
        elif comps[i] == '' and i > 0 and comps[i-1] <> '':
            del comps[i]
        else:
            i = i+1
    # If the path is now empty, substitute '.'
    if not comps and not slashes:
        comps.append(curdir)
    return slashes + string.joinfields(comps, sep) 
Example 19
Project: CTFCrackTools-V2   Author: Acmesec   File: javapath.py    License: GNU General Public License v3.0 5 votes vote down vote up
def normpath(path):
    """Normalize path, eliminating double slashes, etc."""
    sep = os.sep
    if sep == '\\':
        path = path.replace("/", sep)
    curdir = os.curdir
    pardir = os.pardir
    import string
    # Treat initial slashes specially
    slashes = ''
    while path[:1] == sep:
        slashes = slashes + sep
        path = path[1:]
    comps = string.splitfields(path, sep)
    i = 0
    while i < len(comps):
        if comps[i] == curdir:
            del comps[i]
            while i < len(comps) and comps[i] == '':
                del comps[i]
        elif comps[i] == pardir and i > 0 and comps[i-1] not in ('', pardir):
            del comps[i-1:i+1]
            i = i-1
        elif comps[i] == '' and i > 0 and comps[i-1] <> '':
            del comps[i]
        else:
            i = i+1
    # If the path is now empty, substitute '.'
    if not comps and not slashes:
        comps.append(curdir)
    return slashes + string.joinfields(comps, sep) 
Example 20
Project: PokemonGo-DesktopMap   Author: mchristopher   File: dbrecio.py    License: MIT License 5 votes vote down vote up
def writelines(self, list):
        self.write(string.joinfields(list, '')) 
Example 21
Project: CTFCrackTools   Author: Acmesec   File: javapath.py    License: GNU General Public License v3.0 5 votes vote down vote up
def normpath(path):
    """Normalize path, eliminating double slashes, etc."""
    sep = os.sep
    if sep == '\\':
        path = path.replace("/", sep)
    curdir = os.curdir
    pardir = os.pardir
    import string
    # Treat initial slashes specially
    slashes = ''
    while path[:1] == sep:
        slashes = slashes + sep
        path = path[1:]
    comps = string.splitfields(path, sep)
    i = 0
    while i < len(comps):
        if comps[i] == curdir:
            del comps[i]
            while i < len(comps) and comps[i] == '':
                del comps[i]
        elif comps[i] == pardir and i > 0 and comps[i-1] not in ('', pardir):
            del comps[i-1:i+1]
            i = i-1
        elif comps[i] == '' and i > 0 and comps[i-1] <> '':
            del comps[i]
        else:
            i = i+1
    # If the path is now empty, substitute '.'
    if not comps and not slashes:
        comps.append(curdir)
    return slashes + string.joinfields(comps, sep) 
Example 22
Project: CTFCrackTools   Author: Acmesec   File: javapath.py    License: GNU General Public License v3.0 5 votes vote down vote up
def normpath(path):
    """Normalize path, eliminating double slashes, etc."""
    sep = os.sep
    if sep == '\\':
        path = path.replace("/", sep)
    curdir = os.curdir
    pardir = os.pardir
    import string
    # Treat initial slashes specially
    slashes = ''
    while path[:1] == sep:
        slashes = slashes + sep
        path = path[1:]
    comps = string.splitfields(path, sep)
    i = 0
    while i < len(comps):
        if comps[i] == curdir:
            del comps[i]
            while i < len(comps) and comps[i] == '':
                del comps[i]
        elif comps[i] == pardir and i > 0 and comps[i-1] not in ('', pardir):
            del comps[i-1:i+1]
            i = i-1
        elif comps[i] == '' and i > 0 and comps[i-1] <> '':
            del comps[i]
        else:
            i = i+1
    # If the path is now empty, substitute '.'
    if not comps and not slashes:
        comps.append(curdir)
    return slashes + string.joinfields(comps, sep) 
Example 23
Project: keras-lambda   Author: sunilmallya   File: PSDraw.py    License: MIT License 5 votes vote down vote up
def text(self, xy, text):
        text = string.joinfields(string.splitfields(text, "("), "\\(")
        text = string.joinfields(string.splitfields(text, ")"), "\\)")
        xy = xy + (text,)
        self.fp.write("%d %d M (%s) S\n" % xy)