bakalari 0.3.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 52

Bakaláři #

Bakaláři is Dart library that can be used for accessing Bakaweb API. Bakaláři (Bakaweb) is Czech school system. This library allows gathering information like grades, timetable, PMs, or homework.

This library is directly based on vakabus/pybakalib.

If you are at GitHub, the package can be found at pub.dartlang.org.

Install #

Open pubspec.yaml of your project and insert following line into dependencies section:

bakalari: ^0.3.3

Run pub get and it should install automatically.

Use #

Into main.dart, insert this line:

import 'package:bakalari/bakalari.dart';

Create some async method. Instantiate Bakalari class and don't forget to log in (.logIn()). Now, you can call methods like .getGrades() on the instance.

There are two static methods that can be called without instantiating the library: getListOfCitites which returns list of cities in which is at least one school using the Bakaláři system, and getListOfSchools, which returns list of schools using the Bakáláři system in a city.

See example/main.dart for example code.

If you run into problems, create GitHub issue and I'll get into it as soon as possible.

Other community projects #

  • pybakalib is python library that powers the alternative Bakaweb website, Bakaweb.tk.
  • bakalari-api is unofficial documentation of Bakaweb API. Apart from documentation, this organization provides some unofficial apps that use the Bakaweb API.

Version 0.3.3 #

Hashed password is now available at student.key.

Version 0.3.2 #

Added an option to log in with hashed password, removing the need to always prompt for user password.

Updated dependencies.

Version 0.3.1 #

Updated dependencies.

Fixed issues with querying cities which names contain a dot.

Version 0.3.0 #

Moved all class definitions into lib/definitions.dart, so it can be easily imported and used.

Removed school URI fix, as it broke more things than solved - schools do not have any uniform bakaweb address style. Thankfully, there is API endpoint that can be used to find corresponding school address.

So now, you can use this library to get list of citites and schools in these cities - much like in the Bakalari smartphone app.

Version 0.2.3 #

Updated dependencies and removed obsolate method.

Library now tries to fix provided school URI itself. It takes the domain and converts it to https://example.com/login.aspx. Scheme is forced as https.

Let me know if there are any issues with this, and I'll add option to override it or change the URI fix.

Version 0.2.2 #

Fixed spelling. Login failure will throw useful explanation.

Version 0.2.1 #

Library now internally fetches timetable for the next week if it's weekend - so for example, on Saturday, week 1, you'll already see timetable for week 2.

Version 0.2.0 #

Minor fix

Version 0.1.9 #

Timetable serialization hotfix

Version 0.1.8 #

Fixed permanent timetable. Each timetable may now contain more lessons in one time-spot.

Updated pointycastle package.

Version 0.1.7 #

Added option to specify timetable date

Version 0.1.4, 0.1.5, 0.1.6 #

Serialization hotfix

Version 0.1.3 #

Added serialization support (json_serializable)

Version 0.1.2 #

Added homework module and subject list module.

Version 0.1.1 #

Fixed issues with format. Shortened package description.

Version 0.1.0 #

First release.

Package features grades, timetable, PMs, and basic info about student and school.

Package is published on github (/SoptikHa2/bakalari).

example/main.dart

import 'package:bakalari/bakalari.dart';
import 'dart:io';

main(List<String> args) {
  print('Dart example of \'bakalari\' library has loaded.');
  print(
      'Enter your school Uri (for example \'bakalari.ceskolipska.cz\'');
  var uri = stdin.readLineSync();
  print('Enter username');
  var username = stdin.readLineSync();
  print('Enter password');
  stdin.echoMode = false;
  var password = stdin.readLineSync();
  stdin.echoMode = true;

  someAsyncFunction(username, password, uri);
}

/// The code accessing bakaweb should be in special async function.
void someAsyncFunction(String username, String password, String uri) async {
  var bkw = Bakalari(uri);
  await bkw.logIn(username, password);
  print(
      'Welcome, student ${bkw.student.name}, class ${bkw.student.schoolClass} (year: ${bkw.student.year})! '
      'This library has successfully connected to ${bkw.school.name} (${bkw.school.bakawebVersion}). '
      'You can visit the official Bakaweb service by clicking on this link: ${bkw.school.bakawebLink}');

  var grades = await bkw.getGrades();
  for (var grade in grades) {
    print(grade);
  }

  var timetable = await bkw.getTimetable();
  var permTimetable = await bkw.getTimetablePermanent();
  print('Timetable is done!');
  print(
      'Use debug mode to inspect it, I didn\'t write toString method because of it\'s complexity.');

  var pms = await bkw.getMessages();
  print('Messages:');
  for (var message in pms) {
    print(message);
  }

  var hws = await bkw.getHomework();
  for (var hw in hws) {
    print(hw);
  }

  var subjects = await bkw.getSubjects();
  for (var subject in subjects) {
    print(subject);
  }

  // Print serialized list of subjects
  print(subjects.map((s) => s.toJson()));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  bakalari: ^0.3.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:bakalari/bakalari.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
17
Health:
Code health derived from static analysis. [more]
93
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
52
Learn more about scoring.

We analyzed this package on Nov 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:bakalari/bakalari.dart.

Health suggestions

Fix lib/bakalari.dart. (-3.45 points)

Analysis of lib/bakalari.dart reported 7 hints, including:

line 144 col 7: DO use curly braces for all flow control structures.

line 161 col 7: DO use curly braces for all flow control structures.

line 186 col 7: DO use curly braces for all flow control structures.

line 199 col 7: DO use curly braces for all flow control structures.

line 216 col 7: DO use curly braces for all flow control structures.

Fix lib/src/modules/timetableModule.dart. (-2.48 points)

Analysis of lib/src/modules/timetableModule.dart reported 5 hints:

line 20 col 7: Don't explicitly initialize variables to null.

line 26 col 7: DO use curly braces for all flow control structures.

line 28 col 7: DO use curly braces for all flow control structures.

line 95 col 23: Avoid empty catch blocks.

line 100 col 13: DO use curly braces for all flow control structures.

Fix lib/src/listOfSchools.dart. (-0.50 points)

Analysis of lib/src/listOfSchools.dart reported 1 hint:

line 1 col 9: Name libraries using lowercase_with_underscores.

Fix additional 5 files with analysis or formatting issues. (-1 points)

Additional issues in the following files:

  • lib/src/modules/privateMessagesModule.dart (1 hint)
  • lib/src/modules/subjectListModule.dart (1 hint)
  • lib/definitions.dart (Run dartfmt to format lib/definitions.dart.)
  • lib/src/modules/gradeModule.dart (Run dartfmt to format lib/src/modules/gradeModule.dart.)
  • lib/src/modules/homeworkModule.dart (Run dartfmt to format lib/src/modules/homeworkModule.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (intl, json_annotation).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0+2 0.12.0+2
intl ^0.15.8 0.15.8 0.16.0
json_annotation ^2.4.0 2.4.0 3.0.0
pointycastle ^1.0.1 1.0.2
xml ^3.5.0 3.5.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.8.0+1
petitparser 2.4.0
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^1.4.0
json_serializable ^3.0.0