Changeset 2562 for cpc/trunk/project
- Timestamp:
- Jan 3, 2012, 3:19:04 AM (9 years ago)
- Location:
- cpc/trunk/project/batch
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpc/trunk/project/batch/common/common.pm
r2561 r2562 28 28 return $d2 if (!$d1); 29 29 return $d1 if (!$d2); 30 if ($d1 =~ / (\d)+\/(\d+)\/(\d+)/) {30 if ($d1 =~ /^(\d+)\/(\d+)\/(\d+)$/) { 31 31 $y = $3; $m = $2; $d = $1; 32 if ($d2 =~ / (\d)+\/(\d+)\/(\d+)/) {32 if ($d2 =~ /^(\d+)\/(\d+)\/(\d+)$/) { 33 33 return $d1 if ($3 lt $y || ($3 eq $y && $2 lt $m) || ($3 eq $y && $2 eq $m && $1 lt $d)); 34 34 return $d2; -
cpc/trunk/project/batch/depute/parse_depute_new.pl
r2561 r2562 22 22 while ($string =~ s/(<li class="contact-adresse">([^<]*)?)(<\/?p>)+(.*<\/li>(<li class="contact-adresse">|<\/ul>))/\1 \4/gi) {} 23 23 $string =~ s/(<(div|p|li|abbr|img|a|dt)[ >])/\n\1/ig; 24 $string =~ s/\s*'\s*/'/g; 24 25 25 26 if ($display_text) { … … 29 30 30 31 my %depute; 32 33 sub clean_vars { 34 $encours = $lieu = $organisme = $fonction = ""; 35 } 31 36 32 37 sub add_mandat { … … 34 39 $end = shift; 35 40 $cause = shift; 36 $cause =~ s/(remplacement.*)\s*:\s*(.*)\s*$/\1(\2)/i; 37 $depute{'suppleant_de'} = $2 if ($2); 41 if ($cause =~ /(remplacement.*)\s*:\s*(.*)\s*$/i) { 42 $depute{'suppleant_de'} = $2; 43 $cause =~ s/\s*:\s*(.*)\s*$/ \(\1\)/; 44 } 38 45 $depute{'premiers_mandats'}{"$start / $end / ".lc($cause)} = 1; 39 46 $depute{'debut_mandat'} = max_date($start,$depute{'debut_mandat'}); 40 $depute{'fin_mandat'} = max_date($end,$depute{'fin_mandat'}) if ($end i !~ /^$/);47 $depute{'fin_mandat'} = max_date($end,$depute{'fin_mandat'}) if ($end !~ /^$/ && max_date($end,"20/06/2007") != "20/06/2007"); 41 48 } 42 49 … … 91 98 } elsif ($line =~ /Mandat du ([\d\/]+)( \(.*\))? au ([\d\/]+)( \((.*)\))?/i) { 92 99 add_mandat($1,$3,$5); 100 } elsif ($line =~ /class="article-title/) { 101 clean_vars(); 102 $line =~ s/\s*<[^>]+>\s*//g; 103 if ($line =~ /(Bureau|Commissions?|Missions? (temporaire|d'information)s?|Délégations? et Offices?)/i) { 104 $encours = "fonctions"; 105 } elsif ($line =~ /(Organismes? extra-parlementaires?|Fonctions? dans les instances internationales ou judiciaires)/i) { 106 $encours = "extras"; 107 } elsif ($line =~ /(Mandats? loca[lux]+ en cours|Mandats? intercommuna)/i) { 108 $encours = "autresmandats"; 109 } elsif ($line =~ /^Anciens mandats/i && $line !~ /Assemblée nationale/i) { 110 $encours = "anciensmandats"; 111 } elsif ($line =~ /(Groupes? d'études?|Groupes? d'amitié)/i) { 112 $encours = "groupes"; 113 $type_groupe = $line; 114 } 115 } elsif ($line =~ /<div id="/i) { 116 clean_vars(); 117 } elsif ($encours !~ /^$/) { 118 $line =~ s/\s*<[^>]+>\s*//g; 119 next if ($line =~ /^$/); 120 if ($encours =~ /anciensmandats/) { 121 if ($line =~ /du (\d+\/\d+\/\d+) au (\d+\/\d+\/\d+) \((.*)\)/i) { 122 $depute{$encours}{"$lieu / $organisme / $3 / $1 / $2"} = 1; 123 } elsif ($line =~ /^([^(]*) d[elau'\s]+([A-ZÀÉÈÊËÎÏÔÙÛÇ].*)$/) { 124 $organisme = $1; 125 $lieu = $2; 126 $organisme = "Conseil de Paris" if ($lieu =~ s/ \(Département de Paris\)/ (Département)/); 127 } else { 128 $lieu = $line; 129 $organisme = "Communauté d'agglomération"; 130 } 131 } elsif ($encours =~ /autresmandats/) { 132 $lieu = $4 if ($line =~ s/^(.*) d([ue](s| la)? |'|e l')([A-ZÀÉÈÊËÎÏÔÙÛÇ].*)$/\1/); 133 $organisme = ucfirst($4) if ($line =~ s/^(.*) d((u|e la) |e l')(.*)$/\1/); 134 $fonction = $line; 135 $organisme = "Conseil municipal" if ($fonction =~ /Maire/i); 136 $lieu =~ s/, (.*)$/ (\1)/; 137 $depute{$encours}{"$lieu / $organisme / $fonction"} = 1; 138 } elsif ($encours =~ /groupes/ && $line =~ s/^\s*(.*) : - //) { 139 $fonction = $1; 140 $type = "Groupe d'amitié France-"; 141 $type = "Groupe d'études " if ($type_groupe =~ /étude/i); 142 foreach $gpe (split / - /, $line) { 143 $depute{$encours}{"$type$gpe / $fonction"} = 1; 144 } 145 } else { 146 $line =~ s/ (\(ex|depuis le) .*$//; 147 $fonction = $1 if ($line =~ s/^\s*((\S+\s*){1,3}( du bureau)?) d((u|e la) |e l')(.*)$/\6/); 148 $organisme = ucfirst($line); 149 $organisme =~ s/^(Assemblée nationale)/Bureau de l'\1/i; 150 $depute{$encours}{"$organisme / $fonction"} = 1; 151 } 93 152 } 94 153 } … … 100 159 # - multiples sites_web, facebook? tiwtter? 101 160 # - find suppléant si existe 102 # 103 #CHAMPS : 104 #fonctions [ "orga minuscule / fonction / ", "" ] 105 #extras : 106 #autres_mandats: 107 #anciens_autres_mandats: 161 # - add gestion mission tempo 162 # - gérer stockage anciens mandats, premiers_mandats, groupes... 108 163 109 164 #On récupère le nom de famille à partir des emails
Note: See TracChangeset
for help on using the changeset viewer.