File: check_gui

package info (click to toggle)
espresso 5.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 146,004 kB
  • ctags: 17,245
  • sloc: f90: 253,041; sh: 51,271; ansic: 27,494; tcl: 15,570; xml: 14,508; makefile: 2,958; perl: 2,035; fortran: 1,924; python: 337; cpp: 200; awk: 57
file content (150 lines) | stat: -rwxr-xr-x 3,294 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

#
# Usage:   check_gui module
#          ( module = pw, ph, pp, projwfc, atomic, or d3 )
#
# Purpose: check the PWgui modules wrt coprresponding INPUT_*.def
#          files and create a PWgui help files.
#

if { ! [info exists env(PWGUI)] } {
	# try with: ../GUI/PWgui
	set env(PWGUI) [file normalize [file join .. GUI PWgui]]
}
if { ! [info exists env(GUIB)] } {
	# try with: ../GUI/Guib
	set env(GUIB) [file normalize [file join .. GUI Guib]]
}

proc Usage {} {
    global argv0

    puts stderr [subst {
  Usage: $argv0 module
  
  Where module is one of:
  
  \tpw
  \tneb
  \tph 
  \tpp 
  \tprojwfc
  \tbands
  \tdos
  \tatomic
  \td3
    }]
    exit 1
}

if { $argc != 1 } {
    Usage
}

set module [lindex $argv 0]

set basedir [file normalize [file dirname [info script]]]
set topdir  [file normalize [file join $basedir ..]]

# load helpdoc

set helpdocdir [file join $basedir helpdoc.d]
source [file join $helpdocdir helpdoc.tcl]


# load Guib

set guibdir [file join $topdir GUI Guib]
lappend auto_path $guibdir
package require Guib
wm withdraw .


# PWgui's modules dir 

set pwguidir  [file join $topdir GUI PWgui]
set moduledir [file join $pwguidir modules]
source [file join $pwguidir init.tcl]


# map from module to def- and module-file

set mappings {
    pw        PW/Doc     INPUT_PW 
    neb       NEB/Doc    INPUT_NEB
    ph        PHonon/Doc INPUT_PH
    pp        PP/Doc     INPUT_PP
    projwfc   PP/Doc     INPUT_PROJWFC
    bands     PP/Doc     INPUT_BANDS
    dos       PP/Doc     INPUT_DOS
    atomic    atomic/Doc INPUT_LD1
    d3        PHonon/Doc INPUT_D3
}

foreach {mod subdir def_prefix} $mappings {
    if { $mod == $module } {
	set deffile    [file join $topdir $subdir $def_prefix.def]
	set modulefile [file join  $moduledir $mod $mod.tcl]

	# compile the $deffile
	cd [file join $topdir $subdir]
	catch {exec make $def_prefix.html}
	cd $basedir
	
	# output info
	puts "Checking PWgui module: $mod"
	puts "    *     module file: $modulefile"
	puts "    * definition file: $deffile"

	# the current $mod-help.tcl file will interfere the process, rename it:	
	
	if { [file exists [file join $moduledir $mod $mod-help.tcl]] } {
	    puts "Renaming the current $mod-help.tcl file to $mod-help.tcl.bak"
	    file rename -force [file join $moduledir $mod $mod-help.tcl] [file join $moduledir $mod $mod-help.tcl.bak]
	}

	# make a black $mod-help.tcl file

	close [open [file join $moduledir $mod $mod-help.tcl] w]
    } 
}

if { ! [info exists deffile] } {
    Usage
}

# read & load both the def & module file

set def [::helpdoc::def_loadDef $deffile]
set obj [::guib::loadModule $modulefile]; $obj storeModuleItems


#
# check DEF vs. MODULE file
#

::helpdoc::checkGui_def_vs_module

#
# check MODULE vs. DEF file
#

::helpdoc::checkGui_module_vs_def

#
# Create a HELP file
#

::helpdoc::checkGui_makeHelpFile $deffile $modulefile

if { [file exists [file join $moduledir $module $module-help.tcl.bak]] } {
    puts "Renaming back the $module-help.tcl.bak file to $module-help.tcl"
    file rename -force [file join $moduledir $module $module-help.tcl.bak] [file join $moduledir $module $module-help.tcl]
}

# ok, we are done; since we loaded Tk, we need an explicit exit !!!

exit 0