Attachment 'make_plans.py'

Download

   1 #! /usr/bin/env python
   2 # -*- coding: utf-8 -*-
   3 
   4 import urllib, re, locale
   5 
   6 locale.setlocale(locale.LC_ALL, 'ru_RU.UTF-8')
   7 hr=re.compile(r'=== ([^=]+) ===', re.M)
   8 Hr=re.compile(r'== ([^=]+) ==', re.M)
   9 hh=re.compile(r'^\|\|\s+[0-9]+\s+\|\|\s+[0-9]\s+\|\|\s+[0-9]\s+\|\|\s+([1-9])\s+\|\|.*',re.M)
  10 
  11 f = urllib.urlopen('http://uneex.ru/PspoModules?action=raw')
  12 s = f.read()
  13 f.close()
  14 
  15 r = re.compile(r'<<ExtractModules\(([^\)]+)\)>>', re.M).findall(s)
  16 h = hr.findall(s)
  17 
  18 k = 0
  19 for i in h:
  20   d = r[k].split(', ')
  21   k += 1
  22   hrs,incs=0,[]
  23   for j in d:
  24     f = urllib.urlopen('http://uneex.ru/PspoModules' + j + '?action=raw')
  25     ms = f.read()
  26     f.close()
  27     try: t = Hr.findall(ms)[0]
  28     except: t = j
  29     try: c=int(hh.findall(ms)[-1])
  30     except: c=0
  31     hrs+=c
  32     incs.append('<<Include(..%s,"%s (%d)",4,from="^=== Лекционный минимум ===$",to="^[=-]")>>'%(j,t,c))
  33   print '\n'.join(['-----','=== %s (%d) ==='%(i,hrs)]+incs)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.