pax_global_header00006660000000000000000000000064134747566040014532gustar00rootroot0000000000000052 comment=74da92f778522fafc667a09cd4dfa5bf7f57a815 python-simplenote-2.1.4/000077500000000000000000000000001347475660400152345ustar00rootroot00000000000000python-simplenote-2.1.4/.gitignore000066400000000000000000000000641347475660400172240ustar00rootroot00000000000000*.pyc build dist docs/_build .coverage .tox/* *.xml python-simplenote-2.1.4/.travis.yml000066400000000000000000000006201347475660400173430ustar00rootroot00000000000000language: python sudo: false python: - '2.7' - '3.6' script: python tests/test_simplenote.py deploy: provider: pypi user: mrtazz password: secure: pprhp5pZhC6e1drECVnDYnnsHOzCB2otsgKR9s+87TdLum6jiAzSu0Ai9lv3Z77s3Vb3VvjUkENUNC+LA82gvCkUSTBQD7BNLGEAnbT9SqDa+d1BdK5njWiumR92t6q5UyjbO0H6qO7JDEUGakz44aUs1gGBmi/9AS93VL2qwd0= on: python: '2.7' tags: true repo: mrtazz/simplenote.py python-simplenote-2.1.4/CONTRIBUTING.rst000066400000000000000000000026431347475660400177020ustar00rootroot00000000000000============== simplenote.py ============== Contribute =========== You already have code or an idea for code you want to contribute: * Fork the project. * Make your feature addition or bug fix based on master. * Run the tests (See below). * Add tests for your feature if you can and it is appropriate. This is important so I don’t break it in a future version unintentionally. * Commit, do not mess with version. * Send me a pull request, let me know what tests fail as a result of the changes. You don't already have any code, nor any ideas for code, but still want to contribute code somehow: First bear in mind that simplenote.py is fairly stable and feature complete. I don't anticipate much work being required until Simperium finally decide to switch over to the Simperium API. * Have a look through issues labelled "easier" or "harder" depending on how ambitious you are feeling. * Then run through the steps as per above. * Feel free to link to your fork in the issue before submitting a pull request if you want a review. * Or just open the pull request. A pull request doesn't have to start with the finished code. You have ideas/bugs: * Just open an issue with your idea/bug. Tests ====== Before making a pull request or sending a patch it is recommended you run the tests against the most recent version of Python 2 and Python 3. I.e:: python27 tests/test_simplenote.py and:: python34 tests/test_simplenote.py python-simplenote-2.1.4/HISTORY.rst000066400000000000000000000076721347475660400171430ustar00rootroot00000000000000History ======== 2.1.4 (2019-06-02) ------------------ * Handle BadStatusLine errors 2.1.3 (2019-06-01) ------------------ * Fix issue where update_note was actually modifying the external note object passed to it rather than creating a copy and returning that. 2.1.2 (2019-04-07) ------------------ * Fix error in version number 2.1.1 (2019-04-07) ------------------ * Handle invalid/expired tokens * Fixed KeyError in get_note_list() when offline * Fix order of note, status for trash_note 2.1.0 (2018-11-04) ------------------ * Adds since paramter back in (as Simperium cursor, not date) 2.0.3 (2018-10-19) ------------------ * No end facing change in functionality - just removes a superfluous default modificationDate 2.0.2 (2018-10-03) ------------------ * Actually remove the since support like I thought I had. I could have re-implemented since in as per tags so it filters after pulling everything else, but since (ha!) I used "since" for a faster note loading there seems little point. 2.0.1 (2018-10-03) ------------------ * Documentation updatess only 2.0.0 (2018-09-29) ------------------ * Update to the Simperium API: https://simperium.com/docs/http/ * Breaking changes: * The since parameter has been removed. Simperium supports the since parameter, but as a cursor, not a date. * The syncnum key no longer exists (this is an upstream change) * Things seem to be UTF-8 by default * This should largely be a drop in replacement though: E.g. Simperium uses id instead of key, but simplenote.py handles that for you. 1.0.5 (2018-03-24) ------------------- * Sort tags in get_note and update_note 1.0.4 (2018-02-26) ------------------- * Unescape html entites due to api change 1.0.3 (2016-04-03) ------------------- * Bug fix for an error introduce as a result of code review improvements. 1.0.2 (2016-03-18) ------------------- * Code review improvements only. No change to functionality. 1.0.1 (2016-01-13) ------------------- * I ended up pointing tag v1.0.0 at a re-written commit so need to retag. No changes beyond that. 1.0.0 (2015-11-22) ------------------- * I think this is stable and proven enough to be version 1 by now. Can then roll into Simplenote.vim v1. 0.4.0 (2015-03-06) ------------------- * Python 2 and 3 compatibility 0.3.8 (2015-02-16) ------------------- * Fix version number of deploy, now deploying is working 0.3.7 (2015-02-16) ------------------- * Testing deploying to PyPi with a change in credentials 0.3.6 (2015-02-15) ------------------- * Testing deploying to PyPi again, changes to .travis.yml 0.3.5 (2015-02-15) ------------------- * Testing deploying to PyPi again, this time will use an annotate tag 0.3.4 (2015-02-15) ------------------- * Test related changes again (using single instance) * Also testing deploying to PyPi via Travis 0.3.3 (2014-04-07) ------------------- * Minor change to a test, setting it as expected failure. 0.3.2 (2014-04-06) ------------------- * update_note uses utf-8 encoding on returned note content 0.3.1 (2013-12-30) ------------------- * Minor change to Travis CI PyPi deply details 0.3.0 (2013-12-29) ------------------- * Change optional argument for get_note_list() to be "since date" instead of quanity * Various tweaks to tests and CI in attempt to make more robust * get_note_list() now supports optional tag argument * get_note() now supports optional version argument 0.2.0 (2012-06-02) ------------------- * Add optional argument for quantity to get_note_list() * catch HTTPError when fetching notes * immediately return if note could not be fetched * trash_note has to succeed for deleting * add json import fallbacks 0.1.3 (2011-07-17) ------------------- * fix display of '+' signs 0.1.2 (2011-07-02) ------------------- * improved documentation * add sphinx docs 0.1.1 (2011-06-25) ------------------- * minor changes for pypi 0.1.0 (2011-06-25) ------------------- * basic API methods * get note list * get single note * add note * update note * trash note * delete note python-simplenote-2.1.4/LICENSE000066400000000000000000000020461347475660400162430ustar00rootroot00000000000000Copyright (c) 2011 Daniel Schauenberg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. python-simplenote-2.1.4/MANIFEST000066400000000000000000000001201347475660400163560ustar00rootroot00000000000000HISTORY.rst README.rst setup.py simplenote/__init__.py simplenote/simplenote.py python-simplenote-2.1.4/MANIFEST.in000066400000000000000000000000371347475660400167720ustar00rootroot00000000000000include README.rst HISTORY.rst python-simplenote-2.1.4/README.rst000066400000000000000000000052241347475660400167260ustar00rootroot00000000000000============== simplenote.py ============== .. image:: https://readthedocs.org/projects/simplenotepy/badge/?version=latest :target: http://simplenotepy.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://travis-ci.org/mrtazz/simplenote.py.svg?branch=master :target: https://travis-ci.org/mrtazz/simplenote.py .. image:: https://codeclimate.com/github/mrtazz/simplenote.py/badges/gpa.svg :target: https://codeclimate.com/github/mrtazz/simplenote.py :alt: Code Climate .. image:: https://img.shields.io/pypi/v/simplenote.svg :target: https://pypi.python.org/pypi/simplenote :alt: PyPi .. image:: https://img.shields.io/badge/license-MIT-blue.svg :target: http://opensource.org/licenses/MIT :alt: MIT License Introduction ============= simplenote.py is a python library for the simplenote.com_ web service. Installation ============= Install via pip:: pip install simplenote Or if you must:: easy_install simplenote Usage ====== simplenote.py can be imported into any python module:: import simplenote sn = simplenote.Simplenote(user, password) The object then provides the following API methods:: sn.get_note_list(data=True, since=cursor, tags=[]) # Supports optional `tags` parameter that takes a list of tags # to return only notes that contain at least one of these tags. # Also supports a `since` parameter, but as per the Simperium # API this is no longer a date, rather a cursor. # Lastly, also supports a `data` parameter (defaults to True) # to only return keys/ids and versions sn.get_note(note_id) # note id is value of key `key` in note dict as returned # by get_note_list. Supports optional version integer as # argument to return previous versions sn.add_note(note) # A ``note`` object is a dictionary with at least a # ``content`` property, containing the note text. sn.update_note(note) # The ``update_note`` method needs a note object which # also has a ``key`` property. sn.trash_note(note_id) simplenote.delete_note(note_id) .. _simplenote.com: http://simplenoteapp.com python-simplenote-2.1.4/docs/000077500000000000000000000000001347475660400161645ustar00rootroot00000000000000python-simplenote-2.1.4/docs/Makefile000066400000000000000000000110061347475660400176220ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/simplenotepy.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/simplenotepy.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/simplenotepy" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/simplenotepy" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." make -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." python-simplenote-2.1.4/docs/api.rst000066400000000000000000000053731347475660400174770ustar00rootroot00000000000000.. _api: === API === .. module:: simplenote This chapter covers all API interfaces of the simplenote module. --------------------------------------- Historical Simplenote API - Note Object --------------------------------------- Prior to the Simperium API a complete note `dict` object contained the following fields:: { key : (string, note identifier, created by server), deleted : (bool, whether or not note is in trash), modifydate: (last modified date, in seconds since epoch), createdate: (note created date, in seconds since epoch), syncnum : (integer, number set by server, track note changes), version : (integer, number set by server, track note content changes), minversion: (integer, number set by server, minimum version available for note), sharekey : (string, shared note identifier), publishkey: (string, published note identifier), systemtags: [(Array of strings, some set by server)], tags : [(Array of strings)], content : (string, data content) } --------------------------- Simperium API - Note Object --------------------------- Under Simperium some of the fields were renamed and some were removed. String data also seems to be UTF-8 by default. A Simperium note object looks like this:: { deleted : (bool, whether or not note is in trash), modificationDate: (last modified date, in seconds since epoch), creationDate : (note created date, in seconds since epoch), version : (integer, number set by server, track note content changes), shareURL : (string, shared url), publishURL : (string, published note url), systemTags : [(Array of strings, some set by server)], tags : [(Array of strings)], content : (string, data content) } It no longer includes the "key" (actually now an "id", but still not included in the note object). Howver, Simplenote.py tries to work as a drop in replacement for code that expects the older fields and therefore you can still use the following:: { key : (string, note identifier, created by server), deleted : (bool, whether or not note is in trash), modifydate: (last modified date, in seconds since epoch), createdate: (note created date, in seconds since epoch), version : (integer, number set by server, track note content changes), systemtags: [(Array of strings, some set by server)], tags : [(Array of strings)], content : (string, data content) } And simplenote.py will handle conversion to/from the Simperium fields. ----------------------- Simplenote main class ----------------------- .. autoclass:: Simplenote :inherited-members: python-simplenote-2.1.4/docs/conf.py000066400000000000000000000156761347475660400175020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # simplenote.py documentation build configuration file, created by # sphinx-quickstart on Sat Jun 25 17:40:25 2011. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('..')) import simplenote # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'simplenote.py' copyright = u'2011, Daniel Schauenberg' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = simplenote.__version__ # The full version, including alpha/beta/rc tags. release = simplenote.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'simplenotepydoc' # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'simplenotepy.tex', u'simplenote.py Documentation', u'Daniel Schauenberg', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'simplenotepy', u'simplenote.py Documentation', [u'Daniel Schauenberg'], 1) ] python-simplenote-2.1.4/docs/index.rst000066400000000000000000000026521347475660400200320ustar00rootroot00000000000000.. simplenote.py documentation master file, created by sphinx-quickstart on Sat Jun 25 17:40:25 2011. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. simplenote.py: python API wrapper for simplenote.com ========================================================= Contents: .. toctree:: :maxdepth: 2 Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` Quickstart ----------- simplenote.py is a simple wrapper around the simplenote.com web service. It provides the Simplenote object, with a set of convenience methods to interact with the service. First import the module and create an object:: import simplenote sn = simplenote.Simplenote(user, password) This object then provides the following API methods:: sn.get_note_list(tags=) sn.add_note(note) sn.update_note(note) sn.trash_note(note_id) sn.delete_note(note_id) A ``note`` object is a dictionary with at least a ``content`` property, containing the note text. The ``update_note`` method needs a note object which also has a ``key`` property. API Reference ------------- If you are looking for information on a specific function, class or method, you can most likely find it here. .. toctree:: :maxdepth: 2 api python-simplenote-2.1.4/docs/make.bat000066400000000000000000000106531347475660400175760ustar00rootroot00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\simplenotepy.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\simplenotepy.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end python-simplenote-2.1.4/setup.py000066400000000000000000000021451347475660400167500ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- ''' setup.py - distutils script ''' import os import sys import simplenote from distutils.core import setup requires = [] if sys.version_info[:2] < (2,6): requires.append('simplejson') def publish(): """ Publish to PyPi""" os.system("python setup.py sdist upload") if sys.argv[-1] == "publish": publish() sys.exit() setup(name = "simplenote", version = simplenote.__version__, description = "Python library for the simplenote.com API", long_description = (open("README.rst").read() + "\n\n" + open("HISTORY.rst").read()), author = "Daniel Schauenberg", author_email = "d@unwiredcouch.com", url = "https://github.com/mrtazz/simplenote.py", packages = ["simplenote"], install_requires=requires, license = "MIT", classifiers = ( "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ) ) python-simplenote-2.1.4/simplenote/000077500000000000000000000000001347475660400174135ustar00rootroot00000000000000python-simplenote-2.1.4/simplenote/__init__.py000066400000000000000000000002401347475660400215200ustar00rootroot00000000000000# -*- coding: utf-8 -*- from .simplenote import Simplenote, SimplenoteLoginFailed __author__ = "Daniel Schauenberg" __version__ = "2.1.4" __license__ = "MIT" python-simplenote-2.1.4/simplenote/simplenote.py000066400000000000000000000400251347475660400221450ustar00rootroot00000000000000# -*- coding: utf-8 -*- """ simplenote.py ~~~~~~~~~~~~~~ Python library for accessing the Simplenote API :copyright: (c) 2011 by Daniel Schauenberg :license: MIT, see LICENSE for more details. """ import sys if sys.version_info > (3, 0): import urllib.request as urllib2 import urllib.error from urllib.error import HTTPError import urllib.parse as urllib import html from http.client import BadStatusLine else: import urllib2 from urllib2 import HTTPError import urllib from HTMLParser import HTMLParser from httplib import BadStatusLine import base64 import time import datetime import uuid try: import json except ImportError: try: import simplejson as json except ImportError: # For Google AppEngine from django.utils import simplejson as json APP_ID = 'chalk-bump-f49' # There is no way for us to hide this key, only obfuscate it. # So please be kind and don't (ab)use it. # Simplenote/Simperium didn't have to provide us with this. API_KEY = base64.b64decode('YzhjMmI4NjMzNzE1NGNkYWJjOTg5YjIzZTMwYzZiZjQ=') BUCKET = 'note' AUTH_URL = 'https://auth.simperium.com/1/%s/authorize/' % (APP_ID) DATA_URL = 'https://api.simperium.com/1/%s/%s' % (APP_ID, BUCKET) NOTE_FETCH_LENGTH = 1000 class SimplenoteLoginFailed(Exception): pass class Simplenote(object): """ Class for interacting with the simplenote web service """ def __init__(self, username, password): """ object constructor """ self.username = username self.password = password self.header = 'X-Simperium-Token' self.token = None self.current = "" def authenticate(self, user, password): """ Method to get simplenote auth token Arguments: - User (string): simplenote email address - password (string): simplenote password Returns: Simplenote API token as string """ request = Request(AUTH_URL) request.add_header('X-Simperium-API-Key', API_KEY) if sys.version_info < (3, 3): request.add_data(json.dumps({'username': user, 'password': password})) else: request.data = json.dumps({'username': user, 'password': password}).encode() try: res = urllib2.urlopen(request).read() token = json.loads(res.decode('utf-8'))["access_token"] except (HTTPError, BadStatusLine): raise SimplenoteLoginFailed('Login to Simplenote API failed!') except IOError: # no connection exception token = None return token def get_token(self): """ Method to retrieve an auth token. The cached global token is looked up and returned if it exists. If it is `None` a new one is requested and returned. Returns: Simplenote API token as string """ if self.token == None: self.token = self.authenticate(self.username, self.password) try: return str(self.token,'utf-8') except TypeError: return self.token def get_note(self, noteid, version=None): """ Method to get a specific note Arguments: - noteid (string): ID of the note to get - version (int): optional version of the note to get Returns: A tuple `(note, status)` - note (dict): note object - status (int): 0 on success and -1 otherwise """ # request note params_version = "" if version is not None: params_version = '/v/' + str(version) params = '/i/%s%s' % (str(noteid), params_version) request = Request(DATA_URL+params) request.add_header(self.header, self.get_token()) try: response = urllib2.urlopen(request) except HTTPError as e: if e.code == 401: raise SimplenoteLoginFailed('Login to Simplenote API failed! Check Token.') else: return e, -1 except (IOError, BadStatusLine) as e: return e, -1 note = json.loads(response.read().decode('utf-8')) note = self.__add_simplenote_api_fields(note, noteid, int(response.info().get("X-Simperium-Version"))) # Sort tags # For early versions of notes, tags not always available if "tags" in note: note["tags"] = sorted(note["tags"]) return note, 0 def update_note(self, note): """ Method to update a specific note object, if the note object does not have a "key" field, a new note is created Arguments - note (dict): note object to update Returns: A tuple `(note, status)` - note (dict): note object - status (int): 0 on success and -1 otherwise """ # Let's create a copy to work with so we don't alter original note_to_update = note.copy() # determine whether to create a new note or update an existing one # Also need to add/remove key field to keep simplenote.py consistency if "key" in note_to_update: # Then already have a noteid we need to remove before passing to Simperium API noteid = note_to_update.pop("key", None) else: # Adding a new note noteid = uuid.uuid4().hex # TODO: Set a ccid? # ccid = uuid.uuid4().hex if "version" in note_to_update: version = note_to_update.pop("version", None) url = '%s/i/%s/v/%s?response=1' % (DATA_URL, noteid, version) else: url = '%s/i/%s?response=1' % (DATA_URL, noteid) # TODO: Could do with being consistent here. Everywhere else is Request(DATA_URL+params) note_to_update = self.__remove_simplenote_api_fields(note_to_update) request = Request(url, data=json.dumps(note_to_update).encode('utf-8')) request.add_header(self.header, self.get_token()) request.add_header('Content-Type', 'application/json') response = "" try: response = urllib2.urlopen(request) except HTTPError as e: if e.code == 401: raise SimplenoteLoginFailed('Login to Simplenote API failed! Check Token.') else: return e, -1 except (IOError, BadStatusLine) as e: return e, -1 note_to_update = json.loads(response.read().decode('utf-8')) note_to_update = self.__add_simplenote_api_fields(note_to_update, noteid, int(response.info().get("X-Simperium-Version"))) return note_to_update, 0 def add_note(self, note): """ Wrapper method to add a note The method can be passed the note as a dict with the `content` property set, which is then directly send to the web service for creation. Alternatively, only the body as string can also be passed. In this case the parameter is used as `content` for the new note. Arguments: - note (dict or string): the note to add Returns: A tuple `(note, status)` - note (dict): the newly created note - status (int): 0 on success and -1 otherwise """ if type(note) == str: return self.update_note({"content": note}) elif (type(note) == dict) and "content" in note: return self.update_note(note) else: return "No string or valid note.", -1 def get_note_list(self, data=True, since=None, tags=[]): """ Method to get the note list The method can be passed optional arguments to limit the list to notes containing a certain tag, or only updated since a certain Simperium cursor. If omitted a list of all notes is returned. By default data objects are returned. If data is set to false only keys/ids and versions are returned. An empty data object is inserted for compatibility. Arguments: - tags=[] list of tags as string: return notes that have at least one of these tags - since=cursor Simperium cursor as string: return only changes since this cursor - data=True If false only return keys/ids and versions Returns: A tuple `(notes, status)` - notes (list): A list of note objects with all properties set except `content`. - status (int): 0 on success and -1 otherwise """ # initialize data status = 0 ret = [] response_notes = {} notes = { "index" : [] } # get the note index params = '/index?limit=%s' % (str(NOTE_FETCH_LENGTH)) if since is not None: params += '&since=%s' % (since) # Fetching data is the default if data: params += '&data=true' # perform initial HTTP request request = Request(DATA_URL+params) request.add_header(self.header, self.get_token()) try: response = urllib2.urlopen(request) response_notes = json.loads(response.read().decode('utf-8')) # re-write for v1 consistency note_objects = [] for n in response_notes["index"]: # If data=False then can't do this bit... or not all of it, just have id and version. Add empty data object. if not data: n['d'] = {} note_object = self.__add_simplenote_api_fields(n['d'], n['id'], n['v']) note_objects.append(note_object) notes["index"].extend(note_objects) except HTTPError as e: if e.code == 401: raise SimplenoteLoginFailed('Login to Simplenote API failed! Check Token.') else: return e, -1 except (IOError, BadStatusLine) as e: return e, -1 # get additional notes if bookmark was set in response while "mark" in response_notes: params += '&mark=%s' % response_notes["mark"] # perform the actual HTTP request request = Request(DATA_URL+params) request.add_header(self.header, self.get_token()) try: response = urllib2.urlopen(request) response_notes = json.loads(response.read().decode('utf-8')) # re-write for v1 consistency note_objects = [] for n in response_notes["index"]: if not data: n['d'] = {} note_object = n['d'] note_object = self.__add_simplenote_api_fields(n['d'], n['id'], n['v']) note_objects.append(note_object) notes["index"].extend(note_objects) except HTTPError as e: if e.code == 401: raise SimplenoteLoginFailed('Login to Simplenote API failed! Check Token.') else: return e, -1 except (IOError, BadStatusLine) as e: return e, -1 note_list = notes["index"] self.current = response_notes["current"] # Can only filter for tags at end, once all notes have been retrieved. if (len(tags) > 0): note_list = [n for n in note_list if (len(set(n["tags"]).intersection(tags)) > 0)] return note_list, status def trash_note(self, note_id): """ Method to move a note to the trash Arguments: - note_id (string): key of the note to trash Returns: A tuple `(note, status)` - note (dict): the newly created note or an error message - status (int): 0 on success and -1 otherwise """ # get note note, status = self.get_note(note_id) if (status == -1): return note, status # set deleted property, but only if not already trashed # TODO: A 412 is ok, that's unmodified. Should handle this in update_note and # then not worry about checking here if not note["deleted"]: note["deleted"] = True note["modificationDate"] = time.time() # update note return self.update_note(note) else: return note, 0 def delete_note(self, note_id): """ Method to permanently delete a note Arguments: - note_id (string): key of the note to trash Returns: A tuple `(note, status)` - note (dict): an empty dict or an error message - status (int): 0 on success and -1 otherwise """ # notes have to be trashed before deletion note, status = self.trash_note(note_id) if (status == -1): return note, status params = '/i/%s' % (str(note_id)) request = Request(url=DATA_URL+params, method='DELETE') request.add_header(self.header, self.get_token()) try: response = urllib2.urlopen(request) except (IOError, BadStatusLine) as e: return e, -1 except HTTPError as e: if e.code == 401: raise SimplenoteLoginFailed('Login to Simplenote API failed! Check Token.') else: return e, -1 return {}, 0 def __add_simplenote_api_fields(self, note, noteid, version): # Compatibility with original Simplenote API v2.1.5 # We are not creating a copy of the note to work with as these are only # used internally and so doesn't matter if we alter "original" note[u'key'] = noteid note[u'version'] = version try: note[u'modifydate'] = note["modificationDate"] note[u'createdate'] = note["creationDate"] note[u'systemtags'] = note["systemTags"] except KeyError: # For when data=False pass return note def __remove_simplenote_api_fields(self, note): # We are not creating a copy of the note to work with as these are only # used internally and so doesn't matter if we alter "original" # These two should have already removed by this point since they are # needed for updating, etc, but _just_ incase... note.pop("key", None) note.pop("version", None) # Let's only set these ones if they exist. We don't want None so we can # still set defaults afterwards mappings = { "modifydate": "modificationDate", "createdate": "creationDate", "systemtags": "systemTags" } if sys.version_info < (3, 0): for k,v in mappings.iteritems(): if k in note: note[v] = note.pop(k) else: for k,v in mappings.items(): if k in note: note[v] = note.pop(k) # Need to add missing dict stuff if missing, might as well do by # default, not just for note objects only containing content createDate = time.time() note_dict = { "tags" : [], "systemTags" : [], "creationDate" : createDate, "modificationDate" : createDate, "deleted" : False, "shareURL" : "", "publishURL" : "", } if sys.version_info < (3, 0): for k,v in note_dict.iteritems(): note.setdefault(k, v) else: for k,v in note_dict.items(): note.setdefault(k, v) return note class Request(urllib2.Request): """ monkey patched version of urllib2's Request to support HTTP DELETE Taken from http://python-requests.org, thanks @kennethreitz """ if sys.version_info < (3, 0): def __init__(self, url, data=None, headers={}, origin_req_host=None, unverifiable=False, method=None): urllib2.Request.__init__(self, url, data, headers, origin_req_host, unverifiable) self.method = method def get_method(self): if self.method: return self.method return urllib2.Request.get_method(self) else: pass python-simplenote-2.1.4/tests/000077500000000000000000000000001347475660400163765ustar00rootroot00000000000000python-simplenote-2.1.4/tests/test_simplenote.py000066400000000000000000000213161347475660400221710ustar00rootroot00000000000000# -*- coding: utf-8 -*- import unittest import os import sys sys.path.append(os.getcwd()) #Override NOTE_FETCH_LENGTH for testing purposes import simplenote simplenote.simplenote.NOTE_FETCH_LENGTH = 5 class TestSimplenote(unittest.TestCase): @classmethod def setUpClass(cls): cls.user = "simplenote-test@lordofhosts.de" cls.password = "foobar" cls.simplenote_instance = simplenote.Simplenote(cls.user, cls.password) def setUp(self): self.clear_all_notes() self.unicode_note = u'∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫' self.unicode_note_id = False self.initial_note_count = 0 self.tag_note_count = 0 self.first_note = False self.second_note = False note, status = self.simplenote_instance.add_note({"content": "First Note.", "tags": ["tag1"]}) if status == 0: self.initial_note_count += 1 self.tag_note_count += 1 self.first_note = note['key'] note, status = self.simplenote_instance.add_note({"content": "Second Note.", "tags": ["tag1", "tag2"]}) if status == 0: self.initial_note_count += 1 self.tag_note_count += 1 self.second_note = note['key'] note, status = self.simplenote_instance.add_note(self.unicode_note) if status == 0: self.initial_note_count += 1 self.unicode_note_id = note['key'] def tearDown(self): self.clear_all_notes() def test_simplenote_auth(self): token = self.simplenote_instance.get_token() self.assertNotEqual(None, token) def test_simplenote_failed_auth(self): s = simplenote.Simplenote(self.user, "") self.assertRaises(simplenote.SimplenoteLoginFailed, s.get_token) def test_simplenote_get_list_length(self): res, status = self.simplenote_instance.get_note_list() if status == 0: self.assertEqual(self.initial_note_count, len(res)) else: self.assertEqual(0, len(res)) def test_simplenote_get_list_length_longer_than_note_fetch_length(self): while self.initial_note_count <= simplenote.simplenote.NOTE_FETCH_LENGTH+1: note, status = self.simplenote_instance.add_note("Note "+str(self.initial_note_count+1)) if status == 0: self.initial_note_count += 1 res, status = self.simplenote_instance.get_note_list() if status == 0: self.assertTrue(len(res) > simplenote.simplenote.NOTE_FETCH_LENGTH) def test_simplenote_get_list_with_tags(self): res, status = self.simplenote_instance.get_note_list(tags=["tag1"]) if status == 0: self.assertEqual(self.tag_note_count, len(res)) else: self.assertEqual(0, len(res)) # TODO: I can't think of a good way to test this yet since test period is # relatively quick # def test_simplenote_get_list_with_since(self) def test_simplenote_get_list_without_data(self): res, status = self.simplenote_instance.get_note_list(data=False) if status == 0: self.assertEqual(self.initial_note_count, len(res)) else: self.assertEqual(0, len(res)) def test_simplenote_first_note(self): if self.first_note != False: note, status = self.simplenote_instance.get_note(self.first_note) if status == 0: self.assertTrue(type(note) == dict) self.assertEqual("First Note.", note["content"].split('\n')[0]) def test_simplenote_second_note(self): if self.second_note != False: note, status = self.simplenote_instance.get_note(self.second_note) if status == 0: self.assertTrue(type(note) == dict) self.assertEqual("Second Note.", note["content"].split('\n')[0]) def test_simplenote_trash_note(self): if self.first_note != False: note, status = self.simplenote_instance.trash_note(self.first_note) if status == 0: self.assertEqual(1, note["deleted"]) if self.second_note != False: note, status = self.simplenote_instance.trash_note(self.second_note) if status == 0: self.assertEqual(1, note["deleted"]) def test_simplenote_delete_note(self): if self.first_note != False: note, status = self.simplenote_instance.delete_note(self.first_note) if status == 0: note, status = self.simplenote_instance.get_note(self.first_note) self.assertEqual(-1, status) if self.second_note != False: note, status = self.simplenote_instance.delete_note(self.second_note) if status == 0: note, status = self.simplenote_instance.get_note(self.second_note) self.assertEqual(-1, status) def test_simplenote_add_note_object(self): res, status = self.simplenote_instance.add_note({"content": "new note"}) if status == 0: note, status = self.simplenote_instance.get_note(res["key"]) if status == 0: self.assertEqual("new note", note["content"]) def test_simplenote_tags_sorted(self): res, status = self.simplenote_instance.add_note({"content": "A note with tags in any order.", "tags": ["cat", "dog", "ant"]}) if status == 0: note, status = self.simplenote_instance.get_note(res["key"]) if status == 0: self.assertEqual([u'ant', u'cat', u'dog'], note["tags"]) def test_simplenote_add_note_content(self): res, status = self.simplenote_instance.add_note("new note") if status == 0: note, status = self.simplenote_instance.get_note(res["key"]) if status == 0: self.assertEqual("new note", note["content"]) def test_simplenote_update_note(self): note = {} note['key'] = self.first_note note["content"] = "Updated Note." note, status = self.simplenote_instance.update_note(note) if status == 0: note, status = self.simplenote_instance.get_note(note["key"]) if status == 0: self.assertEqual("Updated Note.", note["content"].split('\n')[0]) def test_simplenote_is_unicode(self): if self.unicode_note_id != False: note, status = self.simplenote_instance.get_note(self.unicode_note_id) if status == 0: self.assertTrue(self.is_utf8(note["content"])) def test_html_entity_unescape(self): note, status = self.simplenote_instance.add_note("<>£&'") if status == 0: note, status = self.simplenote_instance.get_note(note["key"]) if status == 0: self.assertEqual(u"<>£&'", note["content"]) def test_note_with_plus_signs(self): note, status = self.simplenote_instance.add_note("++") if status == 0: note, status = self.simplenote_instance.get_note(note["key"]) if status == 0: self.assertEqual("++", note["content"]) def test_note_get_previous_version(self): note_v1, status = self.simplenote_instance.add_note("Hello") if status == 0: note_v2 = {} note_v2['key'] = note_v1["key"] note_v2["content"] = "Goodbye" note_v2, status = self.simplenote_instance.update_note(note_v2) if status == 0: if note_v2["version"] > 1: note, status = self.simplenote_instance.get_note(note_v2["key"], note_v2["version"]-1) if status == 0: self.assertEqual("Hello", note["content"]) def test_external_note_object_does_not_get_altered(self): external_note = {'modifydate': 2.0, 'createdate': 1.0, 'tags': [], 'content': 'note'} reference_note = {'modifydate': 2.0, 'createdate': 1.0, 'tags': [], 'content': 'note'} note, status = self.simplenote_instance.add_note(external_note) if status == 0: self.assertEqual(external_note, reference_note) def is_utf8(self, s): if sys.version_info < (3, 0): try: s.decode('utf-8') return True except UnicodeDecodeError: return False else: return s == self.unicode_note def clear_all_notes(self): res, status = self.simplenote_instance.get_note_list() while (len(res) > 0) and (status == 0): [self.simplenote_instance.delete_note(n["key"]) for n in res] res, status = self.simplenote_instance.get_note_list() if __name__ == '__main__': unittest.main()