1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution. The terms
7 // are also available at
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 // Show information on a package
12 function atomsShow(package)
14 // Load Atoms Internals lib if it's not already loaded
15 // =========================================================================
16 if ~ exists("atomsinternalslib") then
17 load("SCI/modules/atoms/macros/atoms_internals/lib");
22 // Check number of input arguments
23 // =========================================================================
26 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"atomsShow",1));
29 // Check input parameters type
30 // =========================================================================
32 if type(package) <> 10 then
33 error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"atomsShow",1));
36 if size(package(1,:),"*") > 2 then
37 error(msprintf(gettext("%s: Wrong size for input argument #%d: 1x1 or 1x2 string matrix expected.\n"),"atomsShow",1));
40 // Remove leading and trailing parameters
41 // =========================================================================
42 package = stripblanks(package);
44 // If version is not defined, the Most Recent Version is used
45 // =========================================================================
46 if size(package(1,:),"*") == 1 then
47 package(1,2) = atomsGetMRVersion(package(1));
51 // Check if it's a valid package
52 // =========================================================================
53 if size(package(1,:),"*") == 1 then
54 package(1,2) = atomsGetMRVersion(package(1));
59 // Get the details of this package
60 // =========================================================================
62 details = atomsToolboxDetails(package);
65 fields_map = [ fields_map ; "Toolbox" gettext("Package") ];
66 fields_map = [ fields_map ; "Title" gettext("Title") ];
67 fields_map = [ fields_map ; "Summary" gettext("Summary") ];
68 fields_map = [ fields_map ; "Version" gettext("Version") ];
69 fields_map = [ fields_map ; "Depends" gettext("Depend") ];
70 fields_map = [ fields_map ; "Category" gettext("Category(ies)") ];
71 fields_map = [ fields_map ; "Author" gettext("Author(s)") ];
72 fields_map = [ fields_map ; "Maintainer" gettext("Maintainer(s)") ];
73 fields_map = [ fields_map ; "Entity" gettext("Entity") ];
74 fields_map = [ fields_map ; "WebSite" gettext("WebSite") ];
75 fields_map = [ fields_map ; "License" gettext("License") ];
76 fields_map = [ fields_map ; "ScilabVersion" gettext("Scilab Version") ];
78 fields_map = [ fields_map ; "Status" gettext("Status") ];
80 if atomsIsInstalled(package) then
81 fields_map = [ fields_map ; "InstallAutomaticaly" gettext("Automaticaly Installed")];
82 fields_map = [ fields_map ; "installPath" gettext("Install Directory")];
85 fields_map = [ fields_map ; "Description" gettext("Description") ];
88 // =========================================================================
90 max_field_len = max( length(fields_map(:,2)) );
92 for i=1:size(fields_map(:,1),"*")
100 if fields_map(i,1)=="Status" then
101 if atomsIsInstalled(package) then
104 value = "Not installed";
109 // Automaticaly Installed ?
112 if fields_map(i,1)=="InstallAutomaticaly" then
113 if atomsGetInstalledStatus(package) == "A" then
124 if fields_map(i,1)=="ScilabVersion" then
125 if regexp( details(fields_map(i,1)) , "/^~/" , "o" )<>[] then
128 value = details(fields_map(i,1));
136 if fields_map(i,1)=="Depends" then
137 value = dep2str(details(fields_map(i,1)));
144 if isempty(value) then
145 value = details(fields_map(i,1));
148 for j=1:size(value,"*")
151 mprintf("% "+string(max_field_len)+"s : %s\n",fields_map(i,2),value(j))
154 mprintf("% "+string(max_field_len)+"s %s\n","",value(j))
161 // =============================================================================
162 // string = dep2str(string)
164 // Convert a technical dependence string (For ex. : ">= toolbox_1 1.3") to a
165 // display dependence string (For ex. : "toolbox_1 (>= 1.3)" )
167 // =============================================================================
169 function str = dep2str(dep)
177 for i=1:size(dep,"*")
182 this_dep = stripblanks(this_dep);
183 direction_length = regexp(this_dep,"/\s/","o");
184 direction = stripblanks(part(this_dep,1:direction_length-1));
187 this_dep = stripblanks(part(this_dep,direction_length+1:length(this_dep)));
188 name_length = regexp(this_dep,"/\s/","o");
189 name = part(this_dep,1:name_length-1);
192 version = stripblanks(part(this_dep,name_length:length(this_dep)));
196 if direction == "~" then
197 this_str = this_str + "(Any version)";
199 this_str = this_str + "("+direction+" "+version+")";
202 str = [ str ; this_str ];