Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
galaxyproject
GitHub Repository: galaxyproject/training-material
Path: blob/main/bin/check-valid-notebook.rb
1677 views
1
#!/usr/bin/env ruby
2
# frozen_string_literal: true
3
4
require 'json'
5
6
ec = 0
7
ARGV.each do |fn|
8
d = JSON.parse(File.read(fn))
9
10
if !d.is_a?(Hash)
11
puts "#{fn}:0:0:e: This notebook is invalid"
12
ec = 1
13
end
14
15
if d['cells'].empty?
16
puts "#{fn}:0:0:e: This notebook is empty"
17
ec = 1
18
end
19
rescue StandardError
20
puts "#{fn}:0:0:e: This notebook is invalid"
21
ec = 1
22
end
23
24
exit ec
25
26