Created
October 3, 2012 17:51
-
-
Save vssun/3828581 to your computer and use it in GitHub Desktop.
വർഗ്ഗീകരണത്തിനായുള്ള സ്ക്രിപ്റ്റ് x-ൽ ജനിച്ചവർ (ഉദാഹരണം ജനുവരി 1-ന് ജനിച്ചവർ) എന്ന വർഗ്ഗത്തെ x-ന്റെ ഉപവർഗ്ഗമാക്കുക.
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
വർഗ്ഗീകരണത്തിനായുള്ള സ്ക്രിപ്റ്റ് | |
x-ൽ ജനിച്ചവർ (ഉദാഹരണം ജനുവരി 1-ന് ജനിച്ചവർ) എന്ന വർഗ്ഗത്തെ x-ന്റെ ഉപവർഗ്ഗമാക്കുക. | |
നിർമ്മിച്ചത്: സുനിൽ വി.എസ്. | |
തിയതി: 2012-10-03 | |
""" | |
import wikipedia | |
import pagegenerators | |
import catlib | |
#പ്രധാന പ്രോഗ്രാം ഇവിടെ തുടങ്ങുന്നു. | |
#ആവശ്യത്തിനനുസരിച്ച് മാറ്റങ്ങൾ ഇതിനു താഴെ വരുത്തുക | |
siteFamily = 'wikipedia' | |
siteLangCode = 'ml' | |
monthName = ur'ഡിസംബർ' | |
workCatSuffix = ur'-ന് മരിച്ചവർ' | |
#ആവശ്യത്തിനനുസരിച്ച് മാറ്റങ്ങൾ ഇതിനു മുകളിൽ വരുത്തുക | |
wikiSite = wikipedia.Site(code=siteLangCode, fam=siteFamily) | |
for i in range (1, 32): | |
myCategoryPage= catlib.Category(wikiSite, monthName+ " " + str(i) + workCatSuffix) #പ്രവർത്തിക്കേണ്ട വർഗ്ഗം (ഉദാ: ജനുവരി 1-ന് മരിച്ചവർ) | |
myParentCategoryPage = catlib.Category(wikiSite, monthName+ " " + str(i)) #മാതൃവർഗ്ഗം (ഉദാ: ജനുവരി 1) | |
wikipedia.output (myCategoryPage.title() + " " + myParentCategoryPage.title()) | |
#പ്രവർത്തിക്കേണ്ട വർഗ്ഗത്തിൽ മാതൃവർഗ്ഗം നേരത്തേയുണ്ടോ എന്നു നോക്കുന്നു. | |
myParentCategoryExists=False | |
for myTestCategory in myCategoryPage.categories(): | |
if myTestCategory == myParentCategoryPage: | |
myParentCategoryExists=True | |
#പ്രവർത്തിക്കേണ്ട വർഗ്ഗത്തിൽ മാതൃവർഗ്ഗം നേരത്തേയില്ലെങ്കിൽ മാത്രം അത് ചേർക്കുന്നു. | |
if myParentCategoryExists==False: | |
wikipedia.output ("adding category") | |
catlib.add_category(myCategoryPage,myParentCategoryPage,comment="Adding parent category") | |
wikipedia.stopme() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment