Buy Reviews
Powered by MaxBlogPress  

Archive for the ‘Python’ Category

Amara XML工具包

星期三, 三月 10th, 2010

Amara XML工具包是針對XML處理的Python工具的開放原始碼收集,不只是工具,恰巧是用python編寫的,而且其工具是由底層到使用Python用語跟比其他程式語言有更多的優點的Python所建構。

Amara建構在4Suite上,而4Suite更著重在Python裡的XML標準的字面實施,Amara更增加了Python面對這些能力,Amara是開放原始碼,提供了Apache授權的4Suite變形,見檔案COPYING有更多詳細資料。

Akara是一個新的繖形專案,它包括了4Suite跟Amara 2.0做了全面的改善,見AkaraAmara2更多資訊, 我們強烈建議Amara使用這開始轉向Amara2

針對缺乏耐心的:快速安裝

Amara需要Python 2.4或之後的版本以及4Suite-XML 1.0rc4或之後的版本,它支援setuptools,所以你可以就這樣照下面的做:

easy_install amara

假如這沒有作用,你可能不能用easy_install來設定,那我建議你照這些簡單的操作來做。

easy_install會自動地幫你注意安裝的相依性,假如你不喜歡用easy_install,那就抓一個版本比1.0rc4新的Suite-XML套件來裝,然後使用一般方式來安裝Amara套件:

python setup.py install

或使用Windows安裝器,或其他的。

更多細節

Amara提供了你可以相信符合XML標準又不會失去熟悉Python感覺的工具,目前穩定的版本是1.0,開發版本是1.1.9,開發本有很多的效能跟API的改善,但是它不像穩定版那要有實地的測試,Amara最著名的組成部分是Bindery。

Amara Bindery: XML跟py一樣容易

Bindery將XML文件轉成Python物件樹對應使用在XML文件的詞彙,非常的清晰,例如,文件

<monty>
  <python spam="eggs">What do you mean "bleh"</python>
  <python ministry="abuse">But I was looking for argument</python>
</monty>

會變成一個資料結構所以你可以這樣寫:

binding.monty.python.spam

為了取得』eggs』值 (就像Python Unicode物件)或

binding.monty.python[1]

為了取得內容』But I was looking for argument』的元素物件,會有其它像這樣的Python工具,並且使得Bindery獨特之處就是針對繫結XML藉由一個很陳述規則基礎的系統驅動到Python的資料,你可以註冊那些由XPattern表現專門繫結的行為觸發的規則,它包括XPath支援而且很有效率,使用SAX來產生繫結,見使用者文件有更多細節。

使用者注意

開發者注意

Free Articles Input

星期二, 一月 12th, 2010

用 BloggerAds 替自已加薪

Last year I wrote a chinese article “各搜尋引擎的登錄網站” about search engines how to crawl our sites. They use a human-edited directory of the Web.  And the article “關於PageRank” introduces PageRank, Alexarank, BrowseRank and TrustRank. PageRank is a link analysis algorithm. It help us to know the page’s popularity. We need to write unique articles to improve pagerank. So if we have links to our sites on another sites, we can have a good rank. It is a good SEO tactic.

But how do we have links on another sites? I suggest you can input your articles on Article Input.

Recently, I study Python and I found How to create a basic program in Python is good for me. Many people come from a Linux/UNIX background may be familiar with a command line. But like me from a Windows background to use the Python interpreter is no problem. In a script, main is our controlling-and only-function. Ha! Ha! It is like C and Java. I noticed sys.argv, sys.stdin, sys.stdout are different from other languages. And we can understand the fileinput module provides support for processing lines of input from one or more files.

It is a good getting started article and can helps us to learn Python. And the site is similar to my Job Da Ren ‘s WordPress Related Posts Plugin. Like this article have some related articles as follow:

1. How to make Python script execution in UNIX and Mac OS X and in Windows
2. The difference between scripts on Windows scripts on UNIX
3. Python applications are distributed as source files
4. How to use the Python file system
5. Client complaints about inconsistent query results

We can use these free articles to help us to improve our programming skills. But I think the site is new, so I can not find how to submit an article. May be something wrong. And there are not many artilce on the site. So we will spare some time  to wait.

Eclipse for Python, Jython and Iron Python development

星期三, 九月 16th, 2009

時代在快速的進步,就連很新的Google應用服務引擎開發實戰所介紹的工具,也變得有點舊了,就到我用Eclipse還會出錯無法使用,變舊的地方在2-4-1 使用Eclipse,這節介紹用PyDev這個外掛,來讓我們在Eclipse下寫Python程式,書本中所介紹的Eclipse應該是舊版的,我現在則是使用Version: 3.5.0的,從p.38開始圖面一直就不同了,我把圖面更新如下,讓各位參考:

繼續閱讀 »

驗證Python 專用的 Google 應用服務引擎 SDK

星期三, 九月 16th, 2009

在課本Google應用服務引擎開發實戰裡頭2-3-4 驗證SDK安裝這一節指出,Step04,在應用程式的資料夾下,利用dev_appserver.py指令來啟動開發應用伺服器,如果你注意看畫面,就得注意要下dev_appserver.py .
這要的命令才對,另外根據Google的說明文件:dev_appserver.py,你可以到該應用程式的資料夾的上一層目錄,執行這樣的命令:
dev_appserver.py myapp
這樣也可以喔!

Google 應用服務引擎

星期三, 九月 16th, 2009


最近ㄚ琪去圖書館看到這一本Google應用服務引擎開發實戰,封面看起來很新很炫,而且跟之前在Google申請App Engine後就一直沒在動用它,以及最近碰到Google不允許用PHP來查網站的pagerank,因為根據Page Rank PHP Code的說法:『Unfortunately, some IPs may be banned by Google, therefore the server running this code may not be allowed to query the Google servers. In this case the pagerank returned will always be -1.』,我就是那個Unfortunately的人,但是很移問的是使用Python卻可以,但那是上週的事了,是否這個問題是這周產生的就不得而知了,不過使用App Engine卻給了我使用python查詢pagerank的希望!

當我翻開書本進去看時,發現原來App Engine的功能在協助解決伺服器、網路頻寬、資料庫環境,以及網站應用程式所需要的硬體、設備等問題,之後網站開發者就不用擔心機器的電力、網路,以及延展性的問題,為什麼我感到有興趣,因為最近的工作達人好像很慢慢慢喔!我一直在懷疑是硬體、網路及Wordpress有某個地方出問題了,常常慢到還會當機,這種怪異的現象及問題,讓人很傷腦筋,但如果真如作者所言,那使用App Engine卻是一大福音喔!

值得大家努力去玩玩看,我新設的App Engine網址:http://tw-achi.appspot.com

請大家試玩看看,可能你覺得不好玩,但對我的Data Mining很有幫助!

frepple settings.py

星期四, 六月 4th, 2009

frepple中有兩個settings.py會對中文產生影響的:

1.是frepple.nsi在進行方裝時,在bin下會產生一個settings.py,裡頭有一行的LANGUAGE_CODE = ‘zh_tw’ # Language for the user interface,我已經改了

2.是原本就在contrib\django\freppledb下有一個settings.py,裡頭也有這一行LANGUAGE_CODE = ‘en-us’,這一行的en-us也需改成zh_tw,否則中文化一會有一會兒沒有!

Error: Transaction managed block ended with pending COMMIT/ROLLBACK

星期三, 六月 3rd, 2009

今天在測試frepple 0.6.2的時候,我先用了沒有frepple.sqlite,系統安裝時會詢問是否要產生這個檔,但是選yes之後,在使用模式產生器的功能時,卻會發現如題意的錯誤,若是我把舊的frepple.sqlite丟在安裝的bin資料夾下,就不會錯誤了,很納悶,安裝所自行產生的frepple.sqlite倒底有什麼問題?

編譯frepple-0.6.1

星期二, 五月 19th, 2009

1.Xerces找不到,經高人在Google指點,原來是g++沒裝!
2.configure:18531: error:
Can’t link with the python library.
This package requires the python development libraries.

後來Johan De Taeye給我一個提示,就是『Altneratively, you can copy the file libpython25.dll.a from the
cywgin/lib/python25 folder to the cygwin/lib folder.』,我才注意到 libpython25.dll.a這個位置有點詭異!

後來用cygwin編譯證實是沒問題的,不過在編譯frepple.nsi上時發現找不到檔案的問題:

File: 『..\contrib\installer\dist\*.*』 -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
Error in script 『C:\frepple-0.6.1\contrib\installer\frepple.nsi』 on line 161 — aborting creation process

追溯到161行:

; Copy the django and python redistributables created by py2exe
SetOutPath 『$INSTDIR\bin』
File /r 『..\contrib\installer\dist\*.*』

發現怎沒有檔案?有點不懂Copy the django and python redistributables created by py2exe,只好再請教Johan De Taeye,原來需要python setup.py喔!看來自己真是有點耍白癡了!

不過超有成就感的,終於可以自行編譯建置程式了,而且這個程式還是python跨C++使用的,感覺功力大升了!哈!

blocktrans with app.name as name 無法翻譯

星期二, 五月 5th, 2009

當我在進行frepple的翻譯時,赫然發現有個很難的問題:

2009-05-05_135315

這些地方的template經查是像這樣的句子:

<a href=』{{ app.app_url }}』 class=』section』>{% blocktrans with app.name|filter as name %}{{ name }}{% endblocktrans %}</a>

上網查了Google,看到了

修改django自带后台管理页面里的app名称的显示

修改django中blocktrans标签bug

才知道是django的問題,感謝Eric.Zhou的分享!

Python 授權

星期五, 二月 13th, 2009

/! 這一篇是Python license中譯版本。

Python的授權很少限制你可以用Python做什麼,大部分的原始程式碼的著作權是Python軟體基金會的(PSF),少數幾個檔案有不同的著作權者,但是他們都使用同樣的授權方式。

Full text of the Python 2.4.2 license

用外行話來說,這裡有列出Python授權的主要特色,下面的說明沒有法律的諮詢;閱讀授權的全文並且請教合格的專業法律顧問來解釋適用於你的授權條款。

  • Python是完全免費,甚至是商業使用 (包括轉售),你可以用Python寫一個產品販賣或一個產品內嵌Python解器,像這樣的使用不需支付授權費用。
  • 開放源碼促進會已經證明Python授權是開放原始碼,並且將它納入到他們的開放原始碼授權名單中
  • 沒有像GPL這樣的』copyleft』限制, restriction. 只散佈二進位版本的Python,修改會不修改都可以准許,不需要釋出你的原始程式,你也可以設計Python的擴充模組並只用二進位的格式來提供。
  • 然而,Python授權相容於 GPL,根據軟體基金會
  • 你不可以移除PSF的版權公告不管是在原始程式或是二進位的最終版本。