소스 검색

python: Stop using the string module

Most functions in the builtin string module also exist as methods of
string objects.

Since the functions were removed from the string module in Python 3,
using the instance methods directly makes the code compatible with both
Python 2 and Python 3.

Signed-off-by: Mathieu Bridon <bochecha@daitauha.fr>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
tags/18.2-branchpoint
Mathieu Bridon 7 년 전
부모
커밋
fdf946ffbf
4개의 변경된 파일11개의 추가작업 그리고 12개의 파일을 삭제
  1. 1
    2
      src/mapi/glapi/gen/glX_proto_common.py
  2. 4
    4
      src/mapi/glapi/gen/glX_proto_send.py
  3. 4
    4
      src/mapi/glapi/gen/gl_XML.py
  4. 2
    2
      src/mapi/glapi/gen/typeexpr.py

+ 1
- 2
src/mapi/glapi/gen/glX_proto_common.py 파일 보기

@@ -27,7 +27,6 @@
from __future__ import print_function

import gl_XML, glX_XML
import string


class glx_proto_item_factory(glX_XML.glx_item_factory):
@@ -67,7 +66,7 @@ class glx_print_proto(gl_XML.gl_print_base):
return compsize

elif len(param.count_parameter_list):
parameters = string.join( param.count_parameter_list, "," )
parameters = ",".join( param.count_parameter_list )
compsize = "__gl%s_size(%s)" % (func.name, parameters)

return compsize

+ 4
- 4
src/mapi/glapi/gen/glX_proto_send.py 파일 보기

@@ -31,7 +31,7 @@ from __future__ import print_function
import argparse

import gl_XML, glX_XML, glX_proto_common, license
import copy, string
import copy

def convertStringForXCB(str):
tmp = ""
@@ -39,10 +39,10 @@ def convertStringForXCB(str):
i = 0
while i < len(str):
if str[i:i+3] in special:
tmp = '%s_%s' % (tmp, string.lower(str[i:i+3]))
tmp = '%s_%s' % (tmp, str[i:i+3].lower())
i = i + 2;
elif str[i].isupper():
tmp = '%s_%s' % (tmp, string.lower(str[i]))
tmp = '%s_%s' % (tmp, str[i].lower())
else:
tmp = '%s%s' % (tmp, str[i])
i += 1
@@ -662,7 +662,7 @@ generic_%u_byte( GLint rop, const void * ptr )

if len( condition_list ) > 0:
if len( condition_list ) > 1:
skip_condition = "(%s)" % (string.join( condition_list, ") && (" ))
skip_condition = "(%s)" % ") && (".join( condition_list )
else:
skip_condition = "%s" % (condition_list.pop(0))


+ 4
- 4
src/mapi/glapi/gen/gl_XML.py 파일 보기

@@ -29,7 +29,7 @@ from __future__ import print_function
from collections import OrderedDict
from decimal import Decimal
import xml.etree.ElementTree as ET
import re, sys, string
import re, sys
import os.path
import typeexpr
import static_data
@@ -320,7 +320,7 @@ def create_parameter_string(parameters, include_names):

if len(list) == 0: list = ["void"]

return string.join(list, ", ")
return ", ".join(list)


class gl_item(object):
@@ -578,9 +578,9 @@ class gl_parameter(object):
list.append( str(s) )

if len(list) > 1 and use_parens :
return "safe_mul(%s)" % (string.join(list, ", "))
return "safe_mul(%s)" % ", ".join(list)
else:
return string.join(list, " * ")
return " * ".join(list)

elif self.is_image():
return "compsize"

+ 2
- 2
src/mapi/glapi/gen/typeexpr.py 파일 보기

@@ -26,7 +26,7 @@

from __future__ import print_function

import string, copy
import copy

class type_node(object):
def __init__(self):
@@ -126,7 +126,7 @@ class type_expression(object):

# Replace '*' with ' * ' in type_string. Then, split the string
# into tokens, separated by spaces.
tokens = string.split( string.replace( type_string, "*", " * " ) )
tokens = type_string.replace("*", " * ").split()

const = 0
t = None

Loading…
취소
저장