Changeset 495 in ProjectBuilder


Ignore:
Timestamp:
Jul 10, 2008, 11:36:18 AM (16 years ago)
Author:
Bruno Cornec
Message:
  • all global variables are prefixed with pb
  • First attempt at using locale and gettext
  • use of pb_display and pb_display_init added
  • Update presentation following RMLL 2008
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/bin/pbdistrocheck

    r423 r495  
    1919GetOptions("verbose|v+" => \$opts{'v'});
    2020if (defined $opts{'v'}) {
    21     $debug = $opts{'v'};
     21    $pbdebug = $opts{'v'};
    2222}
    2323if (defined $opts{'l'}) {
    24     open(LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
    25     $LOG = \*LOG;
    26     $debug = 0  if ($debug == -1);
     24    open(pbLOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
     25    $pbLOG = \*pbLOG;
     26    $pbdebug = 0  if ($pbdebug == -1);
    2727    }
    28 pb_log_init($debug, $LOG);
     28pb_log_init($pbdebug, $pbLOG);
    2929
    3030my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
  • devel/pb-modules/lib/ProjectBuilder/Base.pm

    r482 r495  
    2020use Pod::Usage;
    2121use English;
     22use locale;
     23use Locale::gettext;
     24use POSIX qw(setlocale);
    2225
    2326# Inherit from the "Exporter" module which handles exporting functions.
     
    2831# any code which uses this module.
    2932 
    30 our $debug = 0;         # Global debug level
    31 our $LOG = \*STDOUT;    # File descriptor of the log file
    32 our $synmsg = "Error";  # Global error message
     33our $pbdebug = 0;       # Global debug level
     34our $pbLOG = \*STDOUT;  # File descriptor of the log file
     35our $pbsynmsg = "Error";    # Global error message
     36our $pbdisplaytype = "text";
     37                        # default display mode for messages
     38our $pblocale = "C";
    3339
    3440our @ISA = qw(Exporter);
    35 our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_get_uri pb_get_content pb_display_file pb_syntax_init pb_syntax pb_temp_init $debug $LOG);
     41our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_display pb_display_init pb_get_uri pb_get_content pb_display_file pb_syntax_init pb_syntax pb_temp_init $pbdebug $pbLOG $pbdisplaytype $pblocale);
    3642
    3743=pod
     
    7985  pb_log_init(2,\*STDOUT);
    8086  pb_log(1,"Message to print\n");
     87
     88  #
     89  # Manages prints of the program
     90  #
     91  pb_display_init("text","fr_FR:UTF-8");
     92  pb_display("Message to print\n");
    8193
    8294  #
     
    220232sub pb_log_init {
    221233
    222 $debug = shift || 0;
    223 $LOG = shift || \*STDOUT;
    224 pb_log(1,"Debug value: $debug\n");
     234$pbdebug = shift || 0;
     235$pbLOG = shift || \*STDOUT;
     236pb_log(1,"Debug value: $pbdebug\n");
    225237
    226238}
     
    249261my $msg = shift;
    250262
    251 print $LOG "$msg" if ($dlevel <= $debug);
     263print $pbLOG "$msg" if ($dlevel <= $pbdebug);
     264}
     265
     266
     267=item B<pb_display_init>
     268
     269This function initializes the environment used by the pb_display function.
     270
     271The first parameter is the type of display which will be used. Could be "text", "web", "newt",...
     272The second parameter is the loacle to be used.
     273
     274The call to B<pb_display_init> is typically done after getting a parameter on the CLI indicating the locale used or the type of interface to report messages to.
     275
     276=cut
     277
     278sub pb_display_init {
     279
     280$pbdisplaytype = shift || "text";
     281$pblocale = shift || "C";
     282
     283setlocale(LC_ALL, $pblocale);
     284pb_log(1,"Using $pbdisplaytype interface with $pblocale locale\n");
     285
     286if ($pbdisplaytype =~ /text/) {
     287} elsif ($pbdisplaytype = /newt/) {
     288} else {
     289    die "display system $pbdisplaytype unsupported";
     290}
     291}
     292
     293=item B<pb_display>
     294
     295This function prints the messages passed as parameter using the configuration set up with the B<pb_display_init> function.
     296
     297Here is a usage example:
     298
     299  pb_display_init("text","fr_FR.UTF-8");
     300  pb_display("Hello World\n");
     301
     302  will print:
     303 
     304  Bonjour Monde
     305
     306=cut
     307
     308sub pb_display {
     309
     310my $msg = shift;
     311
     312if ($pbdisplaytype =~ /text/) {
     313    print STDOUT gettext($msg);
     314    }
    252315}
    253316
     
    298361sub pb_syntax_init {
    299362
    300 $synmsg = shift || "Error";
     363$pbsynmsg = shift || "Error";
    301364}
    302365
     
    320383$filehandle = \*STDOUT if ($exit_status == 0);
    321384
    322 pod2usage( { -message => $synmsg,
     385pod2usage( { -message => $pbsynmsg,
    323386             -exitval => $exit_status  ,
    324387             -verbose => $verbose_level,
  • devel/pb/bin/pb

    r494 r495  
    339339}
    340340if (defined $opts{'v'}) {
    341     $debug = $opts{'v'};
     341    $pbdebug = $opts{'v'};
    342342}
    343343if (defined $opts{'f'}) {
     
    345345}
    346346if (defined $opts{'q'}) {
    347     $debug=-1;
     347    $pbdebug=-1;
    348348}
    349349if (defined $opts{'l'}) {
    350     open(LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
    351     $LOG = \*LOG;
    352     $debug = 0  if ($debug == -1);
    353     }
    354 pb_log_init($debug, $LOG);
     350    open(pbLOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
     351    $pbLOG = \*pbLOG;
     352    $pbdebug = 0  if ($pbdebug == -1);
     353    }
     354pb_log_init($pbdebug, $pbLOG);
     355pb_display_init("text","");
    355356
    356357# Handle root of the project if defined
     
    15281529use File::Copy;
    15291530
    1530 our $debug;
    1531 our $LOG;
    1532 our $synmsg = "pbscript";
    1533 pb_log_init($debug, $LOG);
     1531our $pbdebug;
     1532our $pbLOG;
     1533our $pbsynmsg = "pbscript";
     1534pb_log_init($pbdebug, $pbLOG);
    15341535pb_temp_init();
    15351536
     
    17741775        pb_system("emerge wget sudo ntp DateManip File-MimeInfo","$cmtall");
    17751776} else {
    1776     print "No pkg to install\n";
     1777    pb_log(0,"No pkg to install\n");
    17771778}
    17781779EOF
     
    18391840    # Get subject line
    18401841    my $sl = "Project $ENV{'PBPROJ'} version $ENV{'PBPROJVER'} is now available";
    1841     print "Please enter the title of your announce\n";
    1842     print "(By default: $sl)\n";
     1842    pb_log(0,"Please enter the title of your announce\n");
     1843    pb_log(0,"(By default: $sl)\n");
    18431844    my $sl2 = <STDIN>;
    18441845    $sl = $sl2 if ($sl2 !~ /^$/);
  • projects/buffer/pbconf/1.19/buffer.pb

    r458 r495  
    2424# (containing already a directory with the project-version name)
    2525pbwf buffer = 1
     26
     27# Patches to apply to buffer not upstream
     28pbpatch buffer = svn://svn+ssh/svn.project-builder.org/mondo/svn/projects/buffer/,...
    2629
    2730#
Note: See TracChangeset for help on using the changeset viewer.