Permalink
Browse files

small cleaning

  • Loading branch information...
1 parent e7da6a0 commit cc441441bac3b713bbb95ccb3f703302dce1997a Philippe Makowski committed Mar 2, 2012
Showing with 46 additions and 47 deletions.
  1. +36 −36 fdb/ibase.py
  2. +10 −11 fdb/services.py
View
@@ -51,15 +51,15 @@ def b(s):
return s
def s(s):
return s
- ord2 = lambda x: x
+ ord2 = lambda x: x
if sys.version_info[1] <= 1:
def int2byte(i):
return bytes((i,))
else:
# This is about 2x faster than the implementation above on 3.2+
int2byte = operator.methodcaller("to_bytes", 1, "big")
def mychr(i):
- return i
+ return i
mybytes = bytes
myunicode = str
mylong = int
@@ -79,7 +79,7 @@ def b(s):
s = str
ord2 = ord
def mychr(i):
- return chr(i)
+ return chr(i)
mybytes = str
myunicode = unicode
mylong = long
@@ -393,27 +393,27 @@ def mychr(i):
isc_info_set_page_buffers = 61
# SQL information items
-isc_info_sql_select = 4;
-isc_info_sql_bind = 5;
-isc_info_sql_num_variables = 6;
-isc_info_sql_describe_vars = 7;
-isc_info_sql_describe_end = 8;
-isc_info_sql_sqlda_seq = 9;
-isc_info_sql_message_seq = 10;
-isc_info_sql_type = 11;
-isc_info_sql_sub_type = 12;
-isc_info_sql_scale = 13;
-isc_info_sql_length = 14;
-isc_info_sql_null_ind = 15;
-isc_info_sql_field = 16;
-isc_info_sql_relation = 17;
-isc_info_sql_owner = 18;
-isc_info_sql_alias = 19;
-isc_info_sql_sqlda_start = 20;
-isc_info_sql_stmt_type = 21;
-isc_info_sql_get_plan = 22;
-isc_info_sql_records = 23;
-isc_info_sql_batch_fetch = 24;
+isc_info_sql_select = 4
+isc_info_sql_bind = 5
+isc_info_sql_num_variables = 6
+isc_info_sql_describe_vars = 7
+isc_info_sql_describe_end = 8
+isc_info_sql_sqlda_seq = 9
+isc_info_sql_message_seq = 10
+isc_info_sql_type = 11
+isc_info_sql_sub_type = 12
+isc_info_sql_scale = 13
+isc_info_sql_length = 14
+isc_info_sql_null_ind = 15
+isc_info_sql_field = 16
+isc_info_sql_relation = 17
+isc_info_sql_owner = 18
+isc_info_sql_alias = 19
+isc_info_sql_sqlda_start = 20
+isc_info_sql_stmt_type = 21
+isc_info_sql_get_plan = 22
+isc_info_sql_records = 23
+isc_info_sql_batch_fetch = 24
# SQL information return values
isc_info_sql_stmt_select = 1
@@ -537,19 +537,19 @@ def mychr(i):
isc_spb_process_name = 112
# Service action items
-isc_action_svc_backup = 1 # Starts database backup process on the server
+isc_action_svc_backup = 1 # Starts database backup process on the server
isc_action_svc_restore = 2 # Starts database restore process on the server
-isc_action_svc_repair = 3 # Starts database repair process on the server
+isc_action_svc_repair = 3 # Starts database repair process on the server
isc_action_svc_add_user = 4 # Adds a new user to the security database
-isc_action_svc_delete_user = 5 # Deletes a user record from the security database
-isc_action_svc_modify_user = 6 # Modifies a user record in the security database
-isc_action_svc_display_user = 7 # Displays a user record from the security database
-isc_action_svc_properties = 8 # Sets database properties
-isc_action_svc_add_license = 9 # Adds a license to the license file
-isc_action_svc_remove_license = 10 # Removes a license from the license file
-isc_action_svc_db_stats = 11 # Retrieves database statistics
-isc_action_svc_get_ib_log = 12 # Retrieves the InterBase log file from the server
-isc_action_svc_get_fb_log = 12 # Retrieves the Firebird log file from the server
+isc_action_svc_delete_user = 5 # Deletes a user record from the security database
+isc_action_svc_modify_user = 6 # Modifies a user record in the security database
+isc_action_svc_display_user = 7 # Displays a user record from the security database
+isc_action_svc_properties = 8 # Sets database properties
+isc_action_svc_add_license = 9 # Adds a license to the license file
+isc_action_svc_remove_license = 10 # Removes a license from the license file
+isc_action_svc_db_stats = 11 # Retrieves database statistics
+isc_action_svc_get_ib_log = 12 # Retrieves the InterBase log file from the server
+isc_action_svc_get_fb_log = 12 # Retrieves the Firebird log file from the server
# Service information items
isc_info_svc_svr_db_info = 50 # Retrieves the number of attachments and databases */
@@ -1287,7 +1287,7 @@ class XSQLDA(Structure):
isc_start_multiple.restype = ISC_STATUS
isc_start_multiple.argtypes = [POINTER(ISC_STATUS), POINTER(isc_tr_handle), c_short, c_void_p]
-###
+###
if sys.platform in ['win32','cygwin','os2','os2emx']:
P_isc_start_transaction = CFUNCTYPE(ISC_STATUS,POINTER(ISC_STATUS), POINTER(isc_tr_handle), c_short,POINTER(isc_db_handle),c_short, STRING)
isc_start_transaction = P_isc_start_transaction(('isc_start_transaction',fb_library))
View
@@ -24,7 +24,6 @@
import fdb
import sys
import os
-import types
import fdb.ibase as ibase
import ctypes, struct
import warnings
@@ -152,7 +151,7 @@ def connect(host='service_mgr',
host. Therefore, the database specified as a parameter to methods such as
getStatistics MUST NOT include the host name of the database server.
"""
-
+
if password is None:
raise ProgrammingError('A password is required to use the Services Manager.')
@@ -190,7 +189,7 @@ class Connection(object):
QUERY_TYPE_PLAIN_INTEGER = 1
QUERY_TYPE_PLAIN_STRING = 2
QUERY_TYPE_RAW = 3
-
+
def __init__(self, host, user, password, charset=ibase.DEFAULT_CHARSET):
self._svc_handle = ibase.isc_svc_handle(0)
self._isc_status = ibase.ISC_STATUS_ARRAY()
@@ -215,12 +214,12 @@ def close(self):
raise fdb.exception_from_status(fdb.DatabaseError,self._isc_status,
"Services/isc_service_detach:")
self._svc_handle = None
-
+
def _bytes_to_str(self, b):
if ibase.PYTHON_MAJOR_VER==3:
return b.decode(ibase.charset_map.get(self.charset, self.charset))
else:
- return s.encode(ibase.charset_map.get(self.charset, self.charset))
+ return b.encode(ibase.charset_map.get(self.charset, self.charset))
def _str_to_bytes(self, s):
if ibase.PYTHON_MAJOR_VER==3:
@@ -271,8 +270,8 @@ def _Q(self, code, resultType, timeout = -1):
size = result_size - 1
while result_buffer[size] == '\0':
size -= 1
- result = ibase.s(result_buffer[:size])
-
+ result = ibase.s(result_buffer[:size])
+
return result
def _get_isc_info_svc_svr_db_info(self):
num_attachments = -1
@@ -363,9 +362,9 @@ def _validateCompanionStringNumericSequences(self,
# The core constraint here is that len(numbers) must equal len(strings) - 1
stringsCount = len(strings)
numbersCount = len(numbers)
-
+
requiredNumbersCount = stringsCount - 1
-
+
if numbersCount != requiredNumbersCount:
raise ValueError(
'Since you passed %d %s, you must %s corresponding %s.'
@@ -380,7 +379,7 @@ def _validateCompanionStringNumericSequences(self,
def _excludeElementsOfTypes(self, seq, theTypesToExclude):
if not isinstance(theTypesToExclude, tuple):
theTypesToExclude = tuple(theTypesToExclude)
- return [element for element in seq
+ return [element for element in seq
if not isinstance(element, theTypesToExclude)]
def _requireStrOrTupleOfStr(self,x):
if isinstance(x, ibase.mybytes):
@@ -453,7 +452,7 @@ def getLimboTransactionIDs(self, database):
transIDs = []
i = 0
while i < nBytes:
- byte = ord2(raw[i])
+ byte = ibase.ord2(raw[i])
if byte in (ibase.isc_spb_single_tra_id, ibase.isc_spb_multi_tra_id):
# The transaction ID is a 32-bit integer that begins
# immediately after position i.

0 comments on commit cc44144

Please sign in to comment.