Version 2 (modified by james, 9 years ago)
change my to yb, for consistency

This helps you setup a repo at an arbitrary location, as a user and play with the object. Paste this into a file then run it with ipython for maximum usefulness like:

ipython ./thisfile.py url://to/my/repo

yb = yum.YumBase()
yb.conf.basecachedir = '/tmp/whereever'
if not os.path.exists(yb.conf.basecachedir):
    os.makedirs(yb.conf.basecachedir)
yb.conf.cache = 0
url = sys.argv[1] 

yb.repos.disableRepo('*')

newrepo = yum.yumRepo.YumRepository('myrepo')
newrepo.name = 'myrepo - %s' % url
newrepo.baseurl = [url]
newrepo.basecachedir = yb.conf.basecachedir
newrepo.enablegroups = True
yb.repos.add(newrepo)
yb.repos.enableRepo(newrepo.id)
yb.doRepoSetup(thisrepo=newrepo.id)