Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed auth #12

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
install:
- "pip install -e .[test]"
Expand Down
30 changes: 21 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,33 @@ Open GeoJSON data on `geojson.io <http://geojson.io>`_ from Python.
.. image:: https://travis-ci.org/jwass/geojsonio.py.svg?branch=master
:target: https://travis-ci.org/jwass/geojsonio.py

Usage
Basic and requirements
-----
You must have github3.py
(http://github3py.readthedocs.io)
and import geojsonio

.. code-block:: python

import geojsonio

Auth
_____

Send data to geojson.io and open a browser within python
Edit the __gitauth.txt__ file. In the first line put your github *username*, in the
second your password. It allows the gitHub3 to authenticate and create the gist.

Usage
_____

.. code-block:: python

from geojsonio import display

with open('map.geojson') as f:
contents = f.read()
display(contents)

Data
----
There are two methods by which ``geojsonio.py`` gets geojson.io to render the data:
Expand All @@ -33,7 +47,7 @@ There are two methods by which ``geojsonio.py`` gets geojson.io to render the da
If the contents are small enough, they will be embedded in the URL. Otherwise ``geojsonio.py`` creates an anonymous
Gist on Github with the GeoJSON contents. Note: when an anonymous gist is created, the data is uploaded to Github
and a unique gist ID is created. If anyone else is able to obtain the gist ID, they will be able to see your data.

Goes Great With GeoPandas
-------------------------
``geojsonio.py`` integrates nicely with `GeoPandas <https://github.com/geopandas/geopandas>`_ to
Expand All @@ -46,7 +60,7 @@ property called ``'Name'``. Quickly display all the states whose names start wit

import geopandas as gpd
import geojsonio

states = gpd.read_file('states.geojson')
m_states = states[states['Name'].str.startswith('M')]
geojsonio.display(m_states.to_json())
Expand All @@ -55,7 +69,7 @@ This will open a browser to the geojson.io window with the polygons drawn on the

IPython Notebook Integration
----------------------------

To easily embed geojson.io in an iframe in a Jupyter/IPython notebook, use
the ``embed()`` method

Expand Down Expand Up @@ -87,5 +101,3 @@ Install with ``pip``
::

$ pip install geojsonio


Binary file added geojsonio/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Binary file added geojsonio/__pycache__/geojsonio.cpython-35.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions gitauth.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YOUR_GIT_USER
YOUT_GIT_PASS
107 changes: 107 additions & 0 deletions map.geojson

Large diffs are not rendered by default.

Binary file added tests/__pycache__/test_geojsonio.cpython-35.pyc
Binary file not shown.
8 changes: 7 additions & 1 deletion tests/test_geojsonio.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import geojsonio
import github3
from github3 import login
from github3 import create_gist

import mock
import pytest
Expand Down Expand Up @@ -115,14 +117,18 @@ def test_gist_url():
def test_factory_data(features):
contents = json.dumps(features)
size = len(contents)

url = geojsonio.make_url(contents, size_for_gist=size+1)
assert url == geojsonio.data_url(contents)


def test_factory_gist(features):
contents = json.dumps(features)
size = len(contents)
global gituser
global gitpass
gituser = "gitUsername"
gitpass = "gitPassword"

with mock.patch.object(github3.GitHub, 'create_gist') as MockInstance:
class Dummy(object):
Expand Down