[elbe-devel] [PATCH 08/25] [V2] py3: replace static string functions
Torben Hohn
torben.hohn at linutronix.de
Fri Dec 15 16:51:57 CET 2017
On Fri, Dec 08, 2017 at 07:08:39PM +0100, Manuel Traut wrote:
> strip, join, etc is no longer a static member function of string in python3
>
> Signed-off-by: Manuel Traut <manut at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> elbepack/commands/parselicence.py | 6 +++---
> elbepack/dosunix.py | 7 ++++---
> elbepack/xmldefaults.py | 2 +-
> elbepack/xsdtoasciidoc.mako | 4 ++--
> 4 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/elbepack/commands/parselicence.py b/elbepack/commands/parselicence.py
> index 7316d6e6..baa3b01f 100644
> --- a/elbepack/commands/parselicence.py
> +++ b/elbepack/commands/parselicence.py
> @@ -83,9 +83,9 @@ class license_dep5_to_spdx (dict):
> ands.append (mapped_lic + u" WITH " + with_split[1])
> else:
> ands.append (mapped_lic)
> - ors.append (string.join (ands, u' AND '))
> + ors.append (' AND '.join (ands))
>
> - retval = string.join (ors, u' OR ')
> + retval = ' OR '.join (ors)
> return retval
>
>
> @@ -136,7 +136,7 @@ def license_string (pkg):
> else:
> l_list.append (ll.et.text)
>
> - return string.join (l_list, ' AND ')
> + return ' AND '.join (l_list)
>
>
>
> diff --git a/elbepack/dosunix.py b/elbepack/dosunix.py
> index a8b41833..bb677131 100755
> --- a/elbepack/dosunix.py
> +++ b/elbepack/dosunix.py
> @@ -1,12 +1,13 @@
> #!/usr/bin/env python
>
> -from string import split, join
>
> def dos2unix_str (d):
> - return join (split (d, '\r\n'), '\n')
> + return d.replace('\r\n', '\n')
>
> def unix2dos_str (d):
> - return join (split (dos2unix_str (d), '\n'), '\r\n')
> + d = d.replace('\n', '\r\n')
> + d = d.replace('\r\r\n', '\r\n')
> + return d
>
> def __rewrite (fn, rw_func):
> with open (fn, 'r+') as f:
> diff --git a/elbepack/xmldefaults.py b/elbepack/xmldefaults.py
> index de085852..f9cd0069 100644
> --- a/elbepack/xmldefaults.py
> +++ b/elbepack/xmldefaults.py
> @@ -178,7 +178,7 @@ def get_random_mac():
> binaddr[0] |= 0x02
> s = map( lambda x: "%02x" % x, binaddr )
>
> - return string.join( s, ":" )
> + return ':'.join (s)
>
>
> class ElbeDefaults(object):
> diff --git a/elbepack/xsdtoasciidoc.mako b/elbepack/xsdtoasciidoc.mako
> index 093debdf..c2073bab 100644
> --- a/elbepack/xsdtoasciidoc.mako
> +++ b/elbepack/xsdtoasciidoc.mako
> @@ -12,9 +12,9 @@ MINI = "{http://www.w3.org/2001/XMLSchema}minInclusive"
>
> def docindent( s, indent=0 ):
> lines = s.splitlines()
> - lines = map(string.strip, lines)
> + lines = [l.strip() for l in lines]
> lines = map(lambda x: indent*" "+x, lines)
> - return string.join(lines).strip()
> + return str('').join(lines).strip()
>
> def genlink(typ):
> if typ.startswith("rfs:"):
> --
> 2.15.1
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
--
Mit freundlichen Grüßen
Torben Hohn
Linutronix GmbH
Standort: Bremen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806
Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner
Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20171215/3d3b448c/attachment.sig>
More information about the elbe-devel
mailing list