Skip to content

Commit

Permalink
adapting as Python package
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanhercaz committed May 27, 2018
1 parent dd02393 commit 55f486c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pysemanticmw/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .smw import SemanticMediaWiki
from .smw import APIErrors
File renamed without changes.
8 changes: 4 additions & 4 deletions smwcli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

import argparse
from smw import *
import pysemanticmw as pysmw

config = {
"apiPoint": "https://semantic-mediawiki.org/w/api.php",
Expand Down Expand Up @@ -55,12 +55,12 @@ def main():
query = args.query

if args.api:
smw = SemanticMediaWiki(args.api)
smw = pysmw.SemanticMediaWiki(args.api)
elif config["apiPoint"] is not "":
smw = SemanticMediaWiki(config["apiPoint"])
smw = pysmw.SemanticMediaWiki(config["apiPoint"])
else:
apiPoint = input("Insert the API URL of the Semantic MediaWiki you want to read: ")
smw = SemanticMediaWiki(apiPoint)
smw = pysmw.SemanticMediaWiki(apiPoint)

if args.ask:
action = "ask"
Expand Down
23 changes: 22 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
# -*- coding: utf-8 -*-

from smw import *
import pysemanticmw as pysmw

apiPoint = ""

while apiPoint == "":
if not apiPoint:
apiPoint = input("Insert API URL (e. g., https://sandbox.semantic-mediawiki.org/w/api.php): ")
if not apiPoint:
print("You didn't insert any API URL, please, insert one.")
else:
print("API URL: {}".format(apiPoint))

smw = pysmw.SemanticMediaWiki(apiPoint)

query = "[[Modification date::+]]|?Modification date|sort=Modification date|order=desc"

ask = smw.ask(query, format="json")

print(ask)

'''
Test SemanticMediaWiki > ask()
while apiPoint == "":
if not apiPoint:
apiPoint = input("Insert API URL (e. g., https://www.semantic-mediawiki.org/w/api.php): ")
Expand All @@ -19,3 +38,5 @@
ask = smw.ask(query)
print(ask)
'''

0 comments on commit 55f486c

Please sign in to comment.