1. Jonathan Eunice
  2. quoter

Commits

Jonathan Eunice  committed ecc6578

doc tweaks

  • Participants
  • Parent commits e9b7a5b
  • Branches default

Comments (0)

Files changed (3)

File README.rst

View file
 
     from quoter import single, double, backticks, braces
     
-    print single('this')
-    print double('that')
-    print backticks('ls -l')
-    print braces('curlycue')
-    
-yields::
-
-    'this'
-    "that"
-    `ls -l`
-    {curlycue}
+    print single('this')       # 'this'
+    print double('that')       # "that"
+    print backticks('ls -l')   # `ls -l`
+    print braces('curlycue')   # {curlycue}
 
 .. |laquo| unicode:: 0xAB .. left angle quote
     :rtrim:
 .. |rdquo| unicode:: 0x201D .. right angle quote
     :ltrim:
 
-A handful of the most common quoting styles is pre-defined:
+It pre-defines callable ``Quoters`` for a handful of the most common quoting styles:
 
  *  ``braces``  {example}
  *  ``brackets`` [example]
 <http://en.wikipedia.org/wiki/Quotation_mark_glyphs>`_. There are also `numerous
 bracketing symbols in common use <http://en.wikipedia.org/wiki/Bracket>`_.
 That's to say nothing of the constucts seen in markup, programming, and
-templating languages. Therefore ``quoter`` does not attempt to provide options
-for every possible quoting style. In addition to pre-defining some of the more
-common styles, it provides a general-purpose mechanism for defining your own::
+templating languages. So ``quoter`` couldn't possibly provide an option
+for every possible quoting style. Instead, it provides a general-purpose
+mechanism for defining your own::
 
     from quoter import Quoter
     
     variable = Quoter('${', '}')
     print variable('x')                # ${x}
         
-Note that ``bars`` specifies just one quote symbol. If only one is given,
+Note that ``bars`` is specified with just one symbol. If only one is given,
 the prefix and suffix are considered to be identical. If you really only want
-a prefix or a suffix, and not both, then define the ``Quoter`` with one of them
-as the empty string, as in ``plus`` above. For symmetrical quotes (i.e. where
-the length of the prefix and the suffix is the same), you don't
-have to specify prefix and suffix separately. Use the ``chars`` attribute and
-the given string will be split in two.
+a prefix or a suffix, and not both, then instantiate the ``Quoter`` with two, one
+of which is an empty string, as in ``plus`` above. For symmetrical quotes, where
+the length of the prefix and the suffix are the same, you can specify the prefix
+and suffix all in one go. The prefix will be the first half, the second, the second half
 
 In most cases, it's cleaner and more efficient to define a style, but
 there's nothing preventing you from an on-the-fly usage::
 strings, though usually they will be integers specifying the
 number of spaces surrounding the text.
 
-One can also define the ``encoding`` used for each call, per instance,
-or globally. If some of your quote
-symbox use Unicode characters, yet your output medium doesn't support
-them directly, this is an easy fix. E.g.::
+One can also define the ``encoding`` used for each call, per instance, or
+globally. If some of your quote symbox use Unicode characters, yet your output
+medium doesn't support them directly, this is an easy fix. E.g.::
 
     Quoter.encoding = 'utf-8'
     print curlydouble('something something')
     
     print qs('one'), qd('two'), qb('and'), qt('three')
     # 'one' "two" `and` """three"""
-    
+        
 You can, of course, define your own aliases as well, and/or redefine existing
 styles. If, for example, you like ``braces`` but wish it added a padding space
 by default, it's simple to redefine::

File quoter.py

View file
     
     Instantiate the desired Null values.
     """
-    def __nonzero__(self):
-        """I am always False."""
-        return False
+    if six.PY3:
+        def bool(self):
+            """I am always False."""
+            return False
+    else:
+        def __nonzero__(self):
+            """I am always False."""
+            return False
     
 Default = NullType()
 
             assert prefix is None and suffix is None
             assert len(chars) % 2 == 0
             half = len(chars) / 2
-            self.prefix = unicode(chars[:half])
-            self.suffix = unicode(chars[half:])
+            self.prefix = chars[:half]
+            self.suffix = chars[half:]
         else:
             assert chars is None
-            self.prefix = unicode(prefix)
-            self.suffix = unicode(suffix if suffix is not None else self.prefix)
+            self.prefix = prefix
+            self.suffix = suffix if suffix is not None else self.prefix
         self.padding = padding
         self.margin  = margin
         self.encoding = encoding
 qb, qs, qd, qt = backticks, single, double, triple # short aliases
 
 # and some Unicode styles
-anglequote  = Quoter(u'\u00ab', u'\u00bb', name='anglequote')  # guillemet!
-curlysingle = Quoter(u'\u2018', u'\u2019', name='curlysingle')  
-curlydouble = Quoter(u'\u201c', u'\u201d', name='curlydouble')
+anglequote  = Quoter(six.u('\u00ab'), six.u('\u00bb'), name='anglequote')  # guillemet!
+curlysingle = Quoter(six.u('\u2018'), six.u('\u2019'), name='curlysingle')  
+curlydouble = Quoter(six.u('\u201c'), six.u('\u201d'), name='curlydouble')
 
 class LambdaQuoter(Quoter):
     """
         Create an HTMLQuoter
         """
         tagname, atts = self._parse_selector(tag)
-        self.tag = unicode(tagname)
+        self.tag = tagname
         self.atts = atts or {}
         self.attquote = attquote
         self.void = void

File setup.py

View file
     version=verno("0.102"),
     author='Jonathan Eunice',
     author_email='jonathan.eunice@gmail.com',
-    description="A simple way to quote text",
+    description="A simple way to quote and wrap text",
     long_description=open('README.rst').read(),
     url='https://bitbucket.org/jeunice/quoter',
     py_modules=['quoter'],