Skip to content

Commit

Permalink
Fixed generating names of structures according to PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaifullin committed Jan 8, 2016
1 parent 55e2481 commit f214bf9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def readme():

setup(
name="wsql_sdk",
version="0.3.9",
version="0.3.10",
description='The chain of tools, that to make work with SQL easier',
packages=["wsql_sdk", "wsql_sdk._lang"],
requires=["pyparsing"],
Expand Down
10 changes: 5 additions & 5 deletions test/codegen_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def __query(__connection):
-- CONSTANT CONST2 abc
CREATE TABLE IF NOT EXISTS `table2` (
c1 ENUM('one', 'two'), c2 SET('red', 'blue', 'green')
column_enum ENUM('one', 'two'), column_set SET('red', 'blue', 'green')
);
CREATE PROCEDURE `table2.query` (i BIGINT)
Expand All @@ -342,12 +342,12 @@ def __query(__connection):
from enum import Enum
class C1(Enum):
class ColumnEnum(Enum):
one = 'one'
two = 'two'
class C2(set):
class ColumnSet(set):
__choice = frozenset(('blue', 'green', 'red'))
def __init__(self, v):
Expand Down Expand Up @@ -383,12 +383,12 @@ def __query(__connection):
from enum import Enum
class C1(Enum):
class ColumnEnum(Enum):
one = 'one'
two = 'two'
class C2(set):
class ColumnSet(set):
__choice = frozenset(('blue', 'green', 'red'))
def __init__(self, v):
Expand Down
6 changes: 4 additions & 2 deletions wsql_sdk/_lang/_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ def include_for_structures(kinds):

def declare_structure(kind, name, fields):
"""declare the structure"""
name = name.title().replace("_", "")
if kind == 'ENUM':
return "class {0}(Enum):\n {1}".format(
name.title(), "\n ".join('{0} = {1!r}'.format(x.lower(), x) for x in fields)
name,
"\n ".join('{0} = {1!r}'.format(x.lower(), x) for x in fields)
)

return """\
Expand All @@ -145,4 +147,4 @@ def __init__(self, v):
@property
def value(self):
return self.__value""".format(name.title(), ", ".join(map(repr, fields)))
return self.__value""".format(name, ", ".join(map(repr, fields)))

0 comments on commit f214bf9

Please sign in to comment.