-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1) Add URL Library hooks to Ezhil - readonly -
2) Partial resolution of issue #163 #163; 3) Added unittest 4) update dir() to be called only on non-windows platforms
- Loading branch information
Muthiah Annamalai
committed
Dec 27, 2015
1 parent
bb13d9c
commit 84efd17
Showing
5 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## -*- coding: utf-8 -*- | ||
## (C) 2007, 2008, 2013, 2014, 2015 Muthiah Annamalai, | ||
## Licensed under GPL Version 3 | ||
## | ||
from __future__ import print_function | ||
import sys | ||
from runtime import BuiltinFunction | ||
|
||
PYTHON3 = (sys.version[0] == '3') | ||
|
||
if PYTHON3: | ||
# For Python 3.0 and later | ||
from urllib.request import urlopen | ||
else: | ||
# Fall back to Python 2's urllib2 | ||
from urllib2 import urlopen | ||
|
||
def ezhil_urlopen(*args): | ||
html = urlopen(*args) | ||
return html | ||
|
||
def ezhil_urlread(html): | ||
data = html.read() | ||
if not PYTHON3: | ||
return data.decode("utf-8") | ||
return data | ||
|
||
def ezhil_urlclose(html): | ||
html.close() | ||
|
||
def Load_URL_APIs(interpreter): | ||
interpreter.add_builtin("urlopen",ezhil_urlopen,nargin=1,ta_alias="இணைய_இணைப்பு_திற") | ||
interpreter.add_builtin("urlread",ezhil_urlread,nargin=1,ta_alias="இணைய_இணைப்பு_படி") | ||
interpreter.add_builtin("urlclose",ezhil_urlclose,nargin=1,ta_alias="இணைய_இணைப்பு_மூடு") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,4 @@ partition_estimate.n | |
envchecks.n | ||
ifparse.n | ||
foo.n | ||
urldemo.n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# (C) 2015, Ezhil Language Project | ||
# (C) 2015 முத்தையா அண்ணாமலை | ||
# இது ஒரு எழில் தமிழ் நிரலாக்க மொழி உதாரணம் | ||
|
||
# Networking Example: | ||
# இங்கு 'urllib' Python library functions Ezhil language வழியாக | ||
# பயன் படுத்துமாறு நிரல் எ.கா உள்ளது | ||
|
||
இணைய_முகவரி = "http://www.bing.com" | ||
பிங்_தொடர்பு = urlopen( இணைய_முகவரி ) | ||
அடங்கல் = urlread( பிங்_தொடர்பு ) | ||
|
||
@( sys_platform() != "win32") ஆனால் | ||
பதிப்பி "பிங்_தொடர்பு அடங்கல் => கீழே" | ||
பதிப்பி அடங்கல் | ||
இல்லை | ||
பதிப்பி "Test does not print on Windows" | ||
முடி | ||
|
||
பதிப்பி "Size of contents = ",len(அடங்கல்) | ||
|
||
urlclose( பிங்_தொடர்பு ) | ||
exit(0) |