.like(...,case_sensitive=True), thanks Floyd
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 1.99.4 (2011-12-17 22:07:17) stable
|
Version 1.99.4 (2011-12-18 10:39:51) stable
|
||||||
|
|||||||
@@ -51,7 +51,12 @@ def latex_escape(text,pound=True):
|
|||||||
if pound: text=text.replace('#','\\#')
|
if pound: text=text.replace('#','\\#')
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def render(text,extra={},allowed={},sep='p',image_mapper=lambda x:x):
|
def render(text,
|
||||||
|
extra={},
|
||||||
|
allowed={},
|
||||||
|
sep='p',
|
||||||
|
image_mapper=lambda x:x,
|
||||||
|
chapters=False):
|
||||||
#############################################################
|
#############################################################
|
||||||
# replace all blocks marked with ``...``:class with META
|
# replace all blocks marked with ``...``:class with META
|
||||||
# store them into segments they will be treated as code
|
# store them into segments they will be treated as code
|
||||||
@@ -142,6 +147,11 @@ def render(text,extra={},allowed={},sep='p',image_mapper=lambda x:x):
|
|||||||
#text = regex_quote_left.sub('``',text)
|
#text = regex_quote_left.sub('``',text)
|
||||||
#text = regex_quote_right.sub("''",text)
|
#text = regex_quote_right.sub("''",text)
|
||||||
|
|
||||||
|
if chapters:
|
||||||
|
text=text.replace(r'\section*{',r'\chapter*{')
|
||||||
|
text=text.replace(r'\section{',r'\chapter{')
|
||||||
|
text=text.replace(r'subsection{',r'section{')
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
# process all code text
|
# process all code text
|
||||||
#############################################################
|
#############################################################
|
||||||
@@ -245,7 +255,7 @@ if __name__ == '__main__':
|
|||||||
default=False)
|
default=False)
|
||||||
parser.add_option("-n", "--no_wrapper", dest="no_wrapper",
|
parser.add_option("-n", "--no_wrapper", dest="no_wrapper",
|
||||||
action="store_true",default=False)
|
action="store_true",default=False)
|
||||||
parser.add_option("-1", "--one", dest="one",action="store_true",
|
parser.add_option("-c", "--chapters", dest="chapters",action="store_true",
|
||||||
default=False,help="switch section for chapter")
|
default=False,help="switch section for chapter")
|
||||||
parser.add_option("-w", "--wrapper", dest="wrapper", default=False,
|
parser.add_option("-w", "--wrapper", dest="wrapper", default=False,
|
||||||
help="latex file containing header and footer")
|
help="latex file containing header and footer")
|
||||||
@@ -275,11 +285,9 @@ if __name__ == '__main__':
|
|||||||
finally:
|
finally:
|
||||||
fargs.close()
|
fargs.close()
|
||||||
content = '\n'.join(content_data)
|
content = '\n'.join(content_data)
|
||||||
output= markmin2latex(content,wrapper=wrapper)
|
output= markmin2latex(content,
|
||||||
if options.one:
|
wrapper=wrapper,
|
||||||
output=output.replace(r'\section*{',r'\chapter*{')
|
chapters=options.chapters)
|
||||||
output=output.replace(r'\section{',r'\chapter{')
|
|
||||||
output=output.replace(r'subsection{',r'section{')
|
|
||||||
print output
|
print output
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+21
-7
@@ -943,6 +943,11 @@ class BaseAdapter(ConnectionPool):
|
|||||||
return '(%s IN (%s))' % (self.expand(first), items)
|
return '(%s IN (%s))' % (self.expand(first), items)
|
||||||
|
|
||||||
def LIKE(self, first, second):
|
def LIKE(self, first, second):
|
||||||
|
"case sensitive like operator"
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def ILIKE(self, first, second):
|
||||||
|
"case in-sensitive like operator"
|
||||||
return '(%s LIKE %s)' % (self.expand(first), self.expand(second, 'string'))
|
return '(%s LIKE %s)' % (self.expand(first), self.expand(second, 'string'))
|
||||||
|
|
||||||
def STARTSWITH(self, first, second):
|
def STARTSWITH(self, first, second):
|
||||||
@@ -1908,14 +1913,22 @@ class PostgreSQLAdapter(BaseAdapter):
|
|||||||
self.execute("select currval('%s')" % table._sequence_name)
|
self.execute("select currval('%s')" % table._sequence_name)
|
||||||
return int(self.cursor.fetchone()[0])
|
return int(self.cursor.fetchone()[0])
|
||||||
|
|
||||||
|
|
||||||
def LIKE(self,first,second):
|
def LIKE(self,first,second):
|
||||||
return '(%s ILIKE %s)' % (self.expand(first),self.expand(second,'string'))
|
return '(%s LIKE %s)' % (self.expand(first),
|
||||||
|
self.expand(second,'string'))
|
||||||
|
|
||||||
|
def ILIKE(self,first,second):
|
||||||
|
return '(%s ILIKE %s)' % (self.expand(first),
|
||||||
|
self.expand(second,'string'))
|
||||||
|
|
||||||
def STARTSWITH(self,first,second):
|
def STARTSWITH(self,first,second):
|
||||||
return '(%s ILIKE %s)' % (self.expand(first),self.expand(second+'%','string'))
|
return '(%s ILIKE %s)' % (self.expand(first),
|
||||||
|
self.expand(second+'%','string'))
|
||||||
|
|
||||||
def ENDSWITH(self,first,second):
|
def ENDSWITH(self,first,second):
|
||||||
return '(%s ILIKE %s)' % (self.expand(first),self.expand('%'+second,'string'))
|
return '(%s ILIKE %s)' % (self.expand(first),
|
||||||
|
self.expand('%'+second,'string'))
|
||||||
|
|
||||||
def CONTAINS(self,first,second):
|
def CONTAINS(self,first,second):
|
||||||
if first.type in ('string','text'):
|
if first.type in ('string','text'):
|
||||||
@@ -3174,7 +3187,7 @@ class NoSQLAdapter(BaseAdapter):
|
|||||||
def RANDOM(self): raise SyntaxError, "Not supported"
|
def RANDOM(self): raise SyntaxError, "Not supported"
|
||||||
def SUBSTRING(self,field,parameters): raise SyntaxError, "Not supported"
|
def SUBSTRING(self,field,parameters): raise SyntaxError, "Not supported"
|
||||||
def PRIMARY_KEY(self,key): raise SyntaxError, "Not supported"
|
def PRIMARY_KEY(self,key): raise SyntaxError, "Not supported"
|
||||||
def LIKE(self,first,second): raise SyntaxError, "Not supported"
|
def ILIKE(self,first,second): raise SyntaxError, "Not supported"
|
||||||
def drop(self,table,mode): raise SyntaxError, "Not supported"
|
def drop(self,table,mode): raise SyntaxError, "Not supported"
|
||||||
def alias(self,table,alias): raise SyntaxError, "Not supported"
|
def alias(self,table,alias): raise SyntaxError, "Not supported"
|
||||||
def migrate_table(self,*a,**b): raise SyntaxError, "Not supported"
|
def migrate_table(self,*a,**b): raise SyntaxError, "Not supported"
|
||||||
@@ -4174,7 +4187,7 @@ class MongoDBAdapter(NoSQLAdapter):
|
|||||||
items.append(self.expand(item, first.type) for item in second)
|
items.append(self.expand(item, first.type) for item in second)
|
||||||
return {self.expand(first) : {"$in" : items} }
|
return {self.expand(first) : {"$in" : items} }
|
||||||
|
|
||||||
def LIKE(self, first, second):
|
def ILIKE(self, first, second):
|
||||||
#escaping regex operators?
|
#escaping regex operators?
|
||||||
return {self.expand(first) : ('%s' % self.expand(second, 'string').replace('%','/'))}
|
return {self.expand(first) : ('%s' % self.expand(second, 'string').replace('%','/'))}
|
||||||
|
|
||||||
@@ -5872,8 +5885,9 @@ class Expression(object):
|
|||||||
def __ge__(self, value):
|
def __ge__(self, value):
|
||||||
return Query(self.db, self.db._adapter.GE, self, value)
|
return Query(self.db, self.db._adapter.GE, self, value)
|
||||||
|
|
||||||
def like(self, value):
|
def like(self, value, case_sensitive=False):
|
||||||
return Query(self.db, self.db._adapter.LIKE, self, value)
|
op = case_sensitive and self.db._adapter.LIKE or self.db._adapter.ILIKE
|
||||||
|
return Query(self.db, op, self, value)
|
||||||
|
|
||||||
def belongs(self, value):
|
def belongs(self, value):
|
||||||
return Query(self.db, self.db._adapter.BELONGS, self, value)
|
return Query(self.db, self.db._adapter.BELONGS, self, value)
|
||||||
|
|||||||
Reference in New Issue
Block a user